Fix release version labels across deployment views

This commit is contained in:
2026-10-17 09:45:53 -04:00
parent b5037a70fe
commit ba9bed6a0d
20 changed files with 485 additions and 39 deletions
+28 -3
View File
@@ -171,6 +171,7 @@ function buildRecipe(
path: script.target_rel_path,
versionId: version.id,
version: version.version,
releaseVersion: version.release_version,
sha256: version.sha256,
size: version.size
});
@@ -187,6 +188,7 @@ function buildRecipe(
kind: 'config',
versionId: null,
version: null,
releaseVersion: null,
sha256: sha256Buffer(content),
size: content.length,
...(includeContent ? { content: content.toString('base64') } : {})
@@ -249,18 +251,41 @@ export function recipeSummaryForDeployment(
)
.get(id) as { recipe_summary: string | null; blueprint_name: string | null } | undefined;
if (!row) return null;
if (row.recipe_summary !== null)
return { recipe: JSON.parse(row.recipe_summary), blueprintName: row.blueprint_name };
if (row.recipe_summary !== null) {
const saved: LaunchRecipeSummary = JSON.parse(row.recipe_summary);
const summary = withHistoricalReleaseVersions(saved);
if (summary !== saved)
db()
.prepare(
'UPDATE server_launch_recipes SET recipe_summary = ? WHERE deployment_id = ?'
)
.run(JSON.stringify(summary), id);
return { recipe: summary, blueprintName: row.blueprint_name };
}
// Old snapshots remain readable. Populate on first access, without making
// controller startup scan and decode every retained plugin in its history.
const launch = recipeForDeployment(id)!;
const summary = summarizeRecipe(launch.recipe);
const summary = withHistoricalReleaseVersions(summarizeRecipe(launch.recipe));
db()
.prepare('UPDATE server_launch_recipes SET recipe_summary = ? WHERE deployment_id = ?')
.run(JSON.stringify(summary), id);
return { recipe: summary, blueprintName: row.blueprint_name };
}
/** Restore display metadata from the exact retained upload, preserving the captured recipe. */
function withHistoricalReleaseVersions(summary: LaunchRecipeSummary): LaunchRecipeSummary {
const files = summary.files.map((file) => {
if (file.releaseVersion !== undefined || file.versionId === null) return file;
const version = getVersionMetadata(file.versionId);
if (!version || version.version !== file.version || version.sha256 !== file.sha256)
return file;
return { ...file, releaseVersion: version.release_version };
});
return files.some((file, index) => file !== summary.files[index])
? { ...summary, files }
: summary;
}
export function recipeForDeployment(
id: string
): { recipe: LaunchRecipePlan; blueprintName: string | null } | null {
+7 -2
View File
@@ -192,12 +192,17 @@ export function getVersion(id: number): ScriptVersionRow | undefined {
ScriptVersionRow | undefined;
}
export type ScriptVersionMetadata = Pick<ScriptVersionRow, 'id' | 'version' | 'sha256' | 'size'>;
export type ScriptVersionMetadata = Pick<
ScriptVersionRow,
'id' | 'version' | 'release_version' | 'sha256' | 'size'
>;
/** Planning a launch never needs to load potentially large script or plugin bytes. */
export function getVersionMetadata(id: number): ScriptVersionMetadata | undefined {
return db()
.prepare('SELECT id, version, sha256, size FROM script_versions WHERE id = ?')
.prepare(
'SELECT id, version, release_version, sha256, size FROM script_versions WHERE id = ?'
)
.get(id) as ScriptVersionMetadata | undefined;
}