Fixes #344
This commit is contained in:
+20
-2
@@ -20,14 +20,25 @@ class ConsoleLogger implements Logger {
|
||||
}
|
||||
}
|
||||
|
||||
export type SyncOptions = {
|
||||
logger?: Logger;
|
||||
excludePrefixes?: string[];
|
||||
};
|
||||
|
||||
// Implementation of this algorithm https://unterwaditzer.net/2016/sync-algorithm.html
|
||||
export class SpaceSync {
|
||||
logger: ConsoleLogger;
|
||||
excludePrefixes: string[];
|
||||
|
||||
constructor(
|
||||
private primary: SpacePrimitives,
|
||||
private secondary: SpacePrimitives,
|
||||
readonly snapshot: Map<string, SyncStatusItem>,
|
||||
readonly logger: Logger = new ConsoleLogger(),
|
||||
) {}
|
||||
readonly options: SyncOptions,
|
||||
) {
|
||||
this.logger = options.logger || new ConsoleLogger();
|
||||
this.excludePrefixes = options.excludePrefixes || [];
|
||||
}
|
||||
|
||||
async syncFiles(
|
||||
conflictResolver: (
|
||||
@@ -100,6 +111,13 @@ export class SpaceSync {
|
||||
// console.log("Syncing", name, primaryHash, secondaryHash);
|
||||
let operations = 0;
|
||||
|
||||
// Check if not matching one of the excluded prefixes
|
||||
for (const prefix of this.excludePrefixes) {
|
||||
if (name.startsWith(prefix)) {
|
||||
return operations;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
primaryHash !== undefined && secondaryHash === undefined &&
|
||||
!this.snapshot.has(name)
|
||||
|
||||
Reference in New Issue
Block a user