Skip to content

Commit bbadd2d

Browse files
committed
Harden remaining PR 77 review follow-ups
1 parent e2cabc2 commit bbadd2d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,6 +3406,9 @@ while (attempted.size < Math.max(1, accountCount)) {
34063406
};
34073407

34083408
const SYNC_PRUNE_BACKUP_PREFIX = "codex-sync-prune-backup";
3409+
// Crash-safe prune restores can retain live tokens here when explicitly requested, so
3410+
// keep retention low; pruneOldSyncPruneBackups is the only automatic cleanup gate and
3411+
// Windows still relies on config-home ACLs because `mode: 0o600` is only advisory.
34093412
const SYNC_PRUNE_BACKUP_RETAIN_COUNT = 2;
34103413
const SYNC_PRUNE_BACKUP_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
34113414
const SYNC_PRUNE_BACKUP_RENAME_RETRY_DELAYS_MS = [10, 20, 40, 80, 160] as const;
@@ -3921,14 +3924,14 @@ while (attempted.size < Math.max(1, accountCount)) {
39213924
for (const line of removalPlan.previewLines) {
39223925
console.log(` ${line}`);
39233926
}
3927+
if (!pruneBackup) {
3928+
pruneBackup = await createSyncPruneBackup();
3929+
}
39243930
if (!(await confirm(`Remove ${indexesToRemove.length} selected account(s) and retry sync?`))) {
39253931
await restorePruneBackup();
39263932
console.log("Sync cancelled.\n");
39273933
return;
39283934
}
3929-
if (!pruneBackup) {
3930-
pruneBackup = await createSyncPruneBackup();
3931-
}
39323935
try {
39333936
await removeAccountsForSync(removalPlan.targets);
39343937
} catch (removalError) {
@@ -3978,6 +3981,7 @@ while (attempted.size < Math.max(1, accountCount)) {
39783981
console.log(`Removed overlaps: ${result.removed}`);
39793982
console.log(`Updated synced records: ${result.updated}`);
39803983
console.log(`Backup: ${backupPath}`);
3984+
console.log("Remove this backup after you finish verifying the cleanup.");
39813985
console.log("");
39823986
} catch (error) {
39833987
const message = error instanceof Error ? error.message : String(error);

test/codex-multi-auth-sync.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ describe("codex-multi-auth sync", () => {
242242
it("probes the DevTools fallback root when no env override is set", async () => {
243243
process.env.USERPROFILE = "C:\\Users\\tester";
244244
process.env.HOME = "C:\\Users\\tester";
245+
Object.defineProperty(process, "platform", { value: "win32" });
245246
const devToolsGlobalPath = pathWin32.join(
246247
"C:\\Users\\tester",
247248
"DevTools",
@@ -261,6 +262,7 @@ describe("codex-multi-auth sync", () => {
261262
it("prefers the DevTools root over ~/.codex when CODEX_HOME is not set", async () => {
262263
process.env.USERPROFILE = "C:\\Users\\tester";
263264
process.env.HOME = "C:\\Users\\tester";
265+
Object.defineProperty(process, "platform", { value: "win32" });
264266
const devToolsGlobalPath = pathWin32.join(
265267
"C:\\Users\\tester",
266268
"DevTools",
@@ -290,6 +292,7 @@ describe("codex-multi-auth sync", () => {
290292
process.env.USERPROFILE = "C:\\Users\\tester";
291293
process.env.HOME = "C:\\Users\\tester";
292294
process.env.CODEX_HOME = "C:\\Users\\tester\\.codex";
295+
Object.defineProperty(process, "platform", { value: "win32" });
293296
const walOnlyPath = pathWin32.join(
294297
"C:\\Users\\tester",
295298
".codex",

0 commit comments

Comments
 (0)