Snapshot only committed extensions and publish the last-good marker atomically
This commit is contained in:
+16
-4
@@ -70720,7 +70720,7 @@ async function loadExtensions(harness2, registry3, storage2, models2, context, b
|
||||
const loaderGit = async (...args) => {
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
try {
|
||||
const result = await exec(["git", ...args], { cwd: repo, timeout: 120, signal: commands.signal });
|
||||
const result = await exec(["git", ...args], { cwd: repo, signal: commands.signal });
|
||||
if (result.code) throw new Error(result.stderr || `git exited ${result.code}`);
|
||||
return result.stdout.trim();
|
||||
} catch (error) {
|
||||
@@ -70736,7 +70736,8 @@ async function loadExtensions(harness2, registry3, storage2, models2, context, b
|
||||
const publish2 = async () => {
|
||||
await harness2.commit(async (tx) => Object.assign(await tx.doc(ExtensionState), state2), context);
|
||||
ops2.op_extension_status(JSON.stringify(state2));
|
||||
await fs2.write("/src/sausage/.git/sausage-last-good", state2.good ?? "");
|
||||
await fs2.write("/src/sausage/.git/sausage-last-good.tmp", state2.good ?? "");
|
||||
await fs2.rename("/src/sausage/.git/sausage-last-good.tmp", "/src/sausage/.git/sausage-last-good");
|
||||
};
|
||||
const dispose = async (entries2) => {
|
||||
for (const facet of entries2) for (const cleanup of facet.close) {
|
||||
@@ -70826,8 +70827,19 @@ async function loadExtensions(harness2, registry3, storage2, models2, context, b
|
||||
try {
|
||||
await fs2.stat(snapshot);
|
||||
} catch {
|
||||
await loaderGit("worktree", "prune");
|
||||
await loaderGit("worktree", "add", "--detach", snapshot, sha);
|
||||
const staging = `${snapshot}.tmp`, archive = `${snapshot}.tar`;
|
||||
try {
|
||||
await fs2.mkdir(staging);
|
||||
} catch (error) {
|
||||
if (error.code !== "already_exists") throw error;
|
||||
}
|
||||
if (await loaderGit("ls-tree", "--name-only", sha, "extensions")) {
|
||||
await loaderGit("archive", "--format=tar", `--output=${archive}`, sha, "extensions");
|
||||
const result = await exec(["tar", "-xf", archive, "-C", staging], { cwd: repo, signal: commands.signal });
|
||||
if (result.code) throw new Error(`tar: ${result.stderr || result.code}`);
|
||||
await fs2.remove(archive);
|
||||
}
|
||||
await fs2.rename(staging, snapshot);
|
||||
}
|
||||
const modules = [];
|
||||
for (const entry2 of await fs2.list(`${snapshot}/extensions`).catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user