fix(install): arm rollback before legacy sync

This commit is contained in:
haelyra
2026-08-13 18:30:39 -04:00
parent 42d219e0de
commit 0a7d2787c4
4 changed files with 30 additions and 4 deletions
+3 -3
View File
@@ -208,9 +208,6 @@ if [[ "$MODE" == "apply" ]]; then
--previous-hooks-path "$previous_hooks_path" \
--installed-hooks-path "${ECC_GLOBAL_HOOKS_DIR:-$CODEX_HOME/git-hooks}"
)"
record_managed_path "$CONFIG_FILE"
record_managed_path "$AGENTS_FILE"
rollback_legacy_sync() {
local exit_status="${1:-1}"
trap - ERR INT TERM
@@ -223,6 +220,9 @@ if [[ "$MODE" == "apply" ]]; then
trap 'rollback_legacy_sync $?' ERR
trap 'rollback_legacy_sync 130' INT
trap 'rollback_legacy_sync 143' TERM
record_managed_path "$CONFIG_FILE"
record_managed_path "$AGENTS_FILE"
fi
ECC_BEGIN_MARKER="<!-- BEGIN ECC -->"
+12 -1
View File
@@ -419,7 +419,18 @@ function runLifecycle(options) {
],
};
} finally {
fs.rmSync(tempRoot, { recursive: true, force: true });
try {
fs.rmSync(tempRoot, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 100,
});
} catch (cleanupError) {
process.stderr.write(
`Could not remove lifecycle temp root ${tempRoot}: ${cleanupError.message}\n`
);
}
}
}
@@ -125,6 +125,16 @@ test('public CLI invocations use npm exec instead of internal package paths', ()
assert.ok(!unixInvocation.args.some(argument => argument.includes('node_modules')));
});
test('lifecycle cleanup retries Windows file locks without masking results', () => {
const source = fs.readFileSync(
path.join(__dirname, 'packed-artifact-lifecycle.js'),
'utf8'
);
assert.match(source, /maxRetries:\s*10/);
assert.match(source, /retryDelay:\s*100/);
assert.match(source, /Could not remove lifecycle temp root/);
});
console.log(`\nPassed: ${passed}`);
console.log(`Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
+5
View File
@@ -119,6 +119,11 @@ function runTests() {
assert.match(source, /^set -Eeuo pipefail$/m);
assert.ok(source.includes("trap 'rollback_legacy_sync $?' ERR"));
assert.ok(source.includes('node "$LEGACY_STATE_HELPER" rollback --state "$LEGACY_STATE_PATH"'));
assert.ok(
source.indexOf("trap 'rollback_legacy_sync $?' ERR")
< source.indexOf('record_managed_path "$CONFIG_FILE"'),
'rollback trap must be active before the first ownership record'
);
})) passed++; else failed++;
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);