,,
This commit is contained in:
parent
0c75d3b4c2
commit
3dab48f58b
1 changed files with 1141 additions and 1376 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { v4 as uuid } from "uuid";
|
||||
import type { FileOperations } from "../file-operations/file-operations";
|
||||
import type { EngineState } from "../persistence/database";
|
||||
import type { DocumentId, EngineState, RelativePath } from "../persistence/database";
|
||||
import type { VaultSnapshot } from "../services/types/VaultSnapshot";
|
||||
import { EMPTY_HASH, hash } from "../utils/hash";
|
||||
import {
|
||||
|
|
@ -20,7 +20,7 @@ interface ScanOptions {
|
|||
guard: () => void;
|
||||
changes: LocalChange[];
|
||||
files: FileOperations;
|
||||
ignored: (path: string) => boolean;
|
||||
ignored: (path: RelativePath) => boolean;
|
||||
oversized: (size: number) => boolean;
|
||||
commit: (next: EngineState) => Promise<void>;
|
||||
}
|
||||
|
|
@ -37,16 +37,16 @@ export async function scanLocalFiles(
|
|||
commit
|
||||
}: ScanOptions,
|
||||
initial?: VaultSnapshot
|
||||
): Promise<Set<string>> {
|
||||
): Promise<Set<RelativePath>> {
|
||||
// Leave the prefix queued until its resulting state is saved.
|
||||
// A persisted change ID makes replay safe after an uncertain save.
|
||||
const changes = [...queuedChanges];
|
||||
const unsyncablePaths = new Set<string>();
|
||||
const unsyncablePaths = new Set<RelativePath>();
|
||||
for (const change of unappliedChanges(next, changes)) {
|
||||
applyLocalChange(next, change, ignored, initial);
|
||||
next.lastAppliedLocalChangeId = change.changeId;
|
||||
}
|
||||
const paths: string[] = [];
|
||||
const paths: RelativePath[] = [];
|
||||
const reportedPaths = await files.listFilesRecursively();
|
||||
for (const path of reportedPaths) {
|
||||
// Some filesystems may report a different Unicode spelling after a
|
||||
|
|
@ -61,7 +61,7 @@ export async function scanLocalFiles(
|
|||
);
|
||||
}
|
||||
const present = new Set(paths);
|
||||
const snapshots = new Map<string, { hash: string }>();
|
||||
const snapshots = new Map<RelativePath, { hash: string }>();
|
||||
for (const path of paths) {
|
||||
if (ignored(path)) {
|
||||
unsyncablePaths.add(path);
|
||||
|
|
@ -102,7 +102,7 @@ export async function scanLocalFiles(
|
|||
const sameHash = unknown.filter(
|
||||
(other) => snapshots.get(other)?.hash === snapshot.hash
|
||||
);
|
||||
let id: string | undefined;
|
||||
let id: DocumentId | undefined;
|
||||
if (
|
||||
snapshot.hash !== EMPTY_HASH &&
|
||||
matches.length === 1 &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue