Fix release version labels across deployment views
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user