MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tsc_copy_file

Function tsc_copy_file

tests/test_store_checkpoint.c:322–344  ·  view source on GitHub ↗

#897: any code path installing a fresh DB file must delete the * destination's -wal/-shm first. SQLite decides whether to replay a WAL * purely from the sidecar's own header/checksums — a leftover WAL from a * crashed previous session is recovered ON TOP of the freshly installed * file at the next open, splicing old-generation pages into it (short * indexes, btreeInitPage failures, or resurre

Source from the content-addressed store, hash-verified

320 * cbm_store_dump_to_file, reopen — the stale generation's row must NOT be
321 * visible and the fresh row must be. */
322static int tsc_copy_file(const char *src, const char *dst) {
323 FILE *in = fopen(src, "rb");
324 if (!in) {
325 return -1;
326 }
327 FILE *out = fopen(dst, "wb");
328 if (!out) {
329 (void)fclose(in);
330 return -1;
331 }
332 char buf[4096];
333 size_t n;
334 while ((n = fread(buf, 1, sizeof(buf), in)) > 0) {
335 if (fwrite(buf, 1, n, out) != n) {
336 (void)fclose(in);
337 (void)fclose(out);
338 return -1;
339 }
340 }
341 (void)fclose(in);
342 (void)fclose(out);
343 return 0;
344}
345
346TEST(dump_install_ignores_stale_wal_sidecar) {
347 char *td = th_mktempdir("cbm_stalewal");

Callers 1

Calls 3

fopenFunction · 0.85
freadFunction · 0.85
fwriteFunction · 0.85

Tested by

no test coverage detected