Found during cdidx code-search audit. Evidence: src/CodeIndex/Cli/ExportImportCommandRunner.cs calls DeleteSqliteSidecars(fullDbPath) before File.Move(tempPath, fullDbPath, overwrite: true), then deletes sidecars again after replacement. Impact: if the move fails after the first deletion, the existing live DB remains but its WAL/SHM sidecars may already be removed, risking data loss or forcing recovery outside the successful import path. Suggested fix: replace into a staged path first, use SQLite backup or atomic replacement semantics that preserve the old DB until commit, and delete old sidecars only after the new DB is durably in place.
Found during cdidx code-search audit. Evidence:
src/CodeIndex/Cli/ExportImportCommandRunner.cscallsDeleteSqliteSidecars(fullDbPath)beforeFile.Move(tempPath, fullDbPath, overwrite: true), then deletes sidecars again after replacement. Impact: if the move fails after the first deletion, the existing live DB remains but its WAL/SHM sidecars may already be removed, risking data loss or forcing recovery outside the successful import path. Suggested fix: replace into a staged path first, use SQLite backup or atomic replacement semantics that preserve the old DB until commit, and delete old sidecars only after the new DB is durably in place.