Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: rewrite logFile paths in migrated state.json
After cpSync copies state from tmpdir to the persistent plugin data
dir, job.logFile paths inside state.json still reference the old
/tmp/... location. Replace all occurrences of the fallback dir path
with the new primary dir path in the migrated state file.
  • Loading branch information
tmchow committed Apr 3, 2026
commit 954bc67b7118ae7503552f2a6c3bc74b33b3a13b
12 changes: 12 additions & 0 deletions plugins/codex/scripts/lib/state.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export function resolveStateDir(cwd) {
// future reads/writes use the plugin data dir and state survives tmp cleanup.
if (!fs.existsSync(path.join(primaryDir, STATE_FILE_NAME)) && fs.existsSync(path.join(fallbackDir, STATE_FILE_NAME))) {
fs.cpSync(fallbackDir, primaryDir, { recursive: true });
Comment thread
tmchow marked this conversation as resolved.
// Rewrite logFile paths in migrated state.json so they point to the
// new persistent location instead of the old tmpdir.
const migratedStateFile = path.join(primaryDir, STATE_FILE_NAME);
try {
const raw = fs.readFileSync(migratedStateFile, "utf8");
const updated = raw.replaceAll(fallbackDir, primaryDir);
Comment thread
tmchow marked this conversation as resolved.
Outdated
if (updated !== raw) {
fs.writeFileSync(migratedStateFile, updated, "utf8");
}
} catch {
// Non-fatal: state still works, just with stale log paths
}
}
return primaryDir;
}
Expand Down