fix(import): count the trash when deduplicating by uuid
The map was built from state.entries only, so a container entry whose uuid existed just in the trash looked fresh and inserted a second row sharing that uuid - the identity the sync engine relies on. Same blind spot as the resurrection bug in applyRemoteSnapshot. Also documents F9 and warns that emptying the trash is the wrong way to clean duplicate uuids: the tombstone would kill the live twin on the other device.
This commit is contained in:
@@ -680,8 +680,15 @@ async function doImport() {
|
||||
// exists — the user is either re-importing a backup or rolling
|
||||
// back to an earlier version). Ask what to do with overlapping
|
||||
// entries so a restore isn't silently blocked by the dedup.
|
||||
// The TRASH counts as "already in the vault". Its rows are absent from
|
||||
// state.entries, so without this a container entry whose uuid is only
|
||||
// in the trash was treated as fresh and inserted a SECOND row with the
|
||||
// same uuid — the identity the whole sync engine relies on. Same blind
|
||||
// spot as the resurrection bug in applyRemoteSnapshot (F8).
|
||||
await loadTrash();
|
||||
const localByUuid = new Map();
|
||||
for (const e of state.entries) if (e && e.uuid) localByUuid.set(e.uuid, e);
|
||||
for (const e of (state.trashed || [])) if (e && e.uuid) localByUuid.set(e.uuid, e);
|
||||
const fresh = [];
|
||||
const overlaps = [];
|
||||
for (const e of parsed.entries) {
|
||||
|
||||
Reference in New Issue
Block a user