@@ -23,6 +23,17 @@ export {
2323} from "./storage/identity.js" ;
2424
2525import { normalizeEmailKey } from "./storage/identity.js" ;
26+ import {
27+ ACCOUNTS_BACKUP_SUFFIX ,
28+ ACCOUNTS_WAL_SUFFIX ,
29+ getFlaggedAccountsPath as buildFlaggedAccountsPath ,
30+ getLegacyFlaggedAccountsPath as buildLegacyFlaggedAccountsPath ,
31+ getAccountsBackupPath ,
32+ getAccountsBackupRecoveryCandidates ,
33+ getAccountsWalPath ,
34+ getIntentionalResetMarkerPath ,
35+ RESET_MARKER_SUFFIX ,
36+ } from "./storage/file-paths.js" ;
2637import {
2738 type AccountMetadataV1 ,
2839 type AccountMetadataV3 ,
@@ -54,12 +65,8 @@ const log = createLogger("storage");
5465const ACCOUNTS_FILE_NAME = "openai-codex-accounts.json" ;
5566const FLAGGED_ACCOUNTS_FILE_NAME = "openai-codex-flagged-accounts.json" ;
5667const LEGACY_FLAGGED_ACCOUNTS_FILE_NAME = "openai-codex-blocked-accounts.json" ;
57- const ACCOUNTS_BACKUP_SUFFIX = ".bak" ;
58- const ACCOUNTS_WAL_SUFFIX = ".wal" ;
59- const ACCOUNTS_BACKUP_HISTORY_DEPTH = 3 ;
6068const BACKUP_COPY_MAX_ATTEMPTS = 5 ;
6169const BACKUP_COPY_BASE_DELAY_MS = 10 ;
62- const RESET_MARKER_SUFFIX = ".reset-intent" ;
6370let storageBackupEnabled = true ;
6471let lastAccountsSaveTimestamp = 0 ;
6572
@@ -367,25 +374,6 @@ export function setStorageBackupEnabled(enabled: boolean): void {
367374 storageBackupEnabled = enabled ;
368375}
369376
370- function getAccountsBackupPath ( path : string ) : string {
371- return `${ path } ${ ACCOUNTS_BACKUP_SUFFIX } ` ;
372- }
373-
374- function getAccountsBackupPathAtIndex ( path : string , index : number ) : string {
375- if ( index <= 0 ) {
376- return getAccountsBackupPath ( path ) ;
377- }
378- return `${ path } ${ ACCOUNTS_BACKUP_SUFFIX } .${ index } ` ;
379- }
380-
381- function getAccountsBackupRecoveryCandidates ( path : string ) : string [ ] {
382- const candidates : string [ ] = [ ] ;
383- for ( let i = 0 ; i < ACCOUNTS_BACKUP_HISTORY_DEPTH ; i += 1 ) {
384- candidates . push ( getAccountsBackupPathAtIndex ( path , i ) ) ;
385- }
386- return candidates ;
387- }
388-
389377async function getAccountsBackupRecoveryCandidatesWithDiscovery (
390378 path : string ,
391379) : Promise < string [ ] > {
@@ -425,10 +413,6 @@ async function getAccountsBackupRecoveryCandidatesWithDiscovery(
425413 return [ ...knownCandidates , ...discoveredOrdered ] ;
426414}
427415
428- function getAccountsWalPath ( path : string ) : string {
429- return `${ path } ${ ACCOUNTS_WAL_SUFFIX } ` ;
430- }
431-
432416async function copyFileWithRetry (
433417 sourcePath : string ,
434418 destinationPath : string ,
@@ -605,10 +589,6 @@ function computeSha256(value: string): string {
605589 return createHash ( "sha256" ) . update ( value ) . digest ( "hex" ) ;
606590}
607591
608- function getIntentionalResetMarkerPath ( path : string ) : string {
609- return `${ path } ${ RESET_MARKER_SUFFIX } ` ;
610- }
611-
612592function createEmptyStorageWithMetadata (
613593 restoreEligible : boolean ,
614594 restoreReason : RestoreReason ,
@@ -996,11 +976,14 @@ export async function exportNamedBackup(
996976}
997977
998978export function getFlaggedAccountsPath ( ) : string {
999- return join ( dirname ( getStoragePath ( ) ) , FLAGGED_ACCOUNTS_FILE_NAME ) ;
979+ return buildFlaggedAccountsPath ( getStoragePath ( ) , FLAGGED_ACCOUNTS_FILE_NAME ) ;
1000980}
1001981
1002982function getLegacyFlaggedAccountsPath ( ) : string {
1003- return join ( dirname ( getStoragePath ( ) ) , LEGACY_FLAGGED_ACCOUNTS_FILE_NAME ) ;
983+ return buildLegacyFlaggedAccountsPath (
984+ getStoragePath ( ) ,
985+ LEGACY_FLAGGED_ACCOUNTS_FILE_NAME ,
986+ ) ;
1004987}
1005988
1006989async function migrateLegacyProjectStorageIfNeeded (
0 commit comments