syncWithRemote deletes snapshot records without cleaning up related tables #10

zavřený
otevřeno 2026-02-08 17:16:24 +01:00 uživatelem clawbot · 1 komentář
Spolupracovník

In snapshot.go syncWithRemote(), local snapshots not found in remote are deleted with just:

if err := v.Repositories.Snapshots.Delete(v.ctx, snapshotIDStr); err != nil {

This only deletes the snapshots row. The snapshot_files, snapshot_blobs, and uploads rows are NOT deleted first. Depending on FK constraints, this may either fail (FK violation) or leave orphaned records.

Compare with ListSnapshots() which correctly deletes related records first, and deleteSnapshotFromLocalDB() which also handles this.

Ref: parent issue #1

In `snapshot.go` `syncWithRemote()`, local snapshots not found in remote are deleted with just: ```go if err := v.Repositories.Snapshots.Delete(v.ctx, snapshotIDStr); err != nil { ``` This only deletes the `snapshots` row. The `snapshot_files`, `snapshot_blobs`, and `uploads` rows are NOT deleted first. Depending on FK constraints, this may either fail (FK violation) or leave orphaned records. Compare with `ListSnapshots()` which correctly deletes related records first, and `deleteSnapshotFromLocalDB()` which also handles this. Ref: parent issue #1
clawbot přiřadil/a sobě toto 2026-03-15 22:09:09 +01:00
Autor
Spolupracovník

Closing: this is no longer an issue. PR #44 and PR #46 added ON DELETE CASCADE to all relevant FKs, and FK enforcement is enabled (PRAGMA foreign_keys = ON). Deleting a snapshot row now automatically cascades to delete related snapshot_files, snapshot_blobs, and uploads rows. The explicit cleanup in deleteSnapshotFromLocalDB() is redundant belt-and-suspenders. sneak closed PR #47 as unnecessary for the same reason.

Closing: this is no longer an issue. [PR #44](https://git.eeqj.de/sneak/vaultik/pulls/44) and [PR #46](https://git.eeqj.de/sneak/vaultik/pulls/46) added `ON DELETE CASCADE` to all relevant FKs, and FK enforcement is enabled (`PRAGMA foreign_keys = ON`). Deleting a snapshot row now automatically cascades to delete related `snapshot_files`, `snapshot_blobs`, and `uploads` rows. The explicit cleanup in `deleteSnapshotFromLocalDB()` is redundant belt-and-suspenders. sneak closed [PR #47](https://git.eeqj.de/sneak/vaultik/pulls/47) as unnecessary for the same reason.
clawbot uzavřel/a tento úkol 2026-03-20 06:57:51 +01:00
Přihlaste se pro zapojení do konverzace.
1 účastníků
Oznámení
Termín dokončení
Žádný termín dokončení.
Závislosti

Nejsou nastaveny žádné závislosti.

Reference: sneak/vaultik#10