.
This commit is contained in:
parent
4c002f9acd
commit
b07aa589ff
1 changed files with 728 additions and 530 deletions
|
|
@ -85,7 +85,7 @@ export async function scanLocalFiles(
|
|||
const missing = new Set(
|
||||
Object.keys(next.local).filter(
|
||||
(id) =>
|
||||
next.documents[id]?.materialized &&
|
||||
next.documents[id]?.observedHash !== undefined &&
|
||||
!ignored(next.local[id]) &&
|
||||
!present.has(next.local[id])
|
||||
)
|
||||
|
|
@ -122,10 +122,7 @@ export async function scanLocalFiles(
|
|||
}
|
||||
id ??= uuid();
|
||||
next.local[id] = path;
|
||||
next.documents[id] ??= {
|
||||
materialized: true,
|
||||
bootstrap: initial?.fileManifest.entries[id] !== undefined
|
||||
};
|
||||
next.documents[id] ??= { observedHash: "" };
|
||||
}
|
||||
for (const id of missing) delete next.local[id];
|
||||
for (const [id, path] of Object.entries(next.local)) {
|
||||
|
|
@ -136,14 +133,20 @@ export async function scanLocalFiles(
|
|||
}
|
||||
const snapshot = snapshots.get(path);
|
||||
if (snapshot) {
|
||||
next.documents[id] ??= { materialized: true };
|
||||
if (!next.documents[id].materialized && !next.documents[id].base)
|
||||
next.documents[id].bootstrap = true;
|
||||
next.documents[id].materialized = true;
|
||||
next.documents[id].observedHash = snapshot.hash;
|
||||
const doc = (next.documents[id] ??= {});
|
||||
// The old history no longer contains this base. Preserve any edit
|
||||
// made during recovery as a new file instead of overwriting it.
|
||||
if (
|
||||
doc.base?.vaultUpdateId === null &&
|
||||
doc.base.hash !== snapshot.hash
|
||||
) {
|
||||
const recoveredId = uuid();
|
||||
next.local[recoveredId] = path;
|
||||
next.documents[recoveredId] = { observedHash: snapshot.hash };
|
||||
delete next.local[id];
|
||||
} else doc.observedHash = snapshot.hash;
|
||||
}
|
||||
}
|
||||
next.protectedPaths = [...unsyncablePaths];
|
||||
guard();
|
||||
await commit(next);
|
||||
queuedChanges.splice(0, changes.length);
|
||||
|
|
|
|||
Loading…
Reference in a new issue