mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-25 06:11:02 +02:00
fix(browse): write self-contained .gstack/.gitignore unconditionally
ensureStateDir only appended .gstack/ to the project .gitignore when that file already existed, skipped silently on ENOENT, and swallowed other append failures. With BROWSE_PERSIST_STATE=1, session-state.json (live cookies + localStorage/sessionStorage tokens) and browse-network.log / browse-audit.jsonl (request headers) then sat git-add-able under <git-root>/.gstack/. Write a self-contained <stateDir>/.gitignore containing "*" unconditionally, before return, so the state dir's contents can never be committed regardless of the project .gitignore. The project-.gitignore append is kept as redundant safety. The no-import-side-effects guard is relaxed to allow exactly this lone .gitignore guard file (still fails on browse.json / session-state.json / logs / listener binds) — the guard is written eagerly by ensureStateDir at import and is not leaked state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
57a1d957f4
commit
4992a48c57
@@ -42,9 +42,13 @@ const sigtermAfter = process.listenerCount('SIGTERM');
|
||||
const uncaughtAfter = process.listenerCount('uncaughtException');
|
||||
|
||||
// Check that the gstack home directory wasn't populated as a side effect.
|
||||
// A lone \`.gitignore\` (the state-dir ignore guard, contents "*") is expected
|
||||
// and is NOT leaked state — ensureStateDir writes it so persisted cookies/logs
|
||||
// can never be git-committed. Any OTHER entry (browse.json, session-state.json,
|
||||
// logs) would be a real auto-start write and must still fail the guard.
|
||||
let gstackPopulated = false;
|
||||
try {
|
||||
const entries = fs.readdirSync(${JSON.stringify(tmpGstack)});
|
||||
const entries = fs.readdirSync(${JSON.stringify(tmpGstack)}).filter(e => e !== '.gitignore');
|
||||
gstackPopulated = entries.length > 0;
|
||||
} catch {
|
||||
// Doesn't exist — that's the win we want.
|
||||
|
||||
Reference in New Issue
Block a user