@@ -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 ) ;
0 commit comments