@filen/sync 0.2.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.node-version +1 -1
- package/dist/ignorer.d.ts +6 -0
- package/dist/ignorer.js +43 -24
- package/dist/ignorer.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/deltas.d.ts +58 -2
- package/dist/lib/deltas.js +693 -108
- package/dist/lib/deltas.js.map +1 -1
- package/dist/lib/environment.d.ts +47 -0
- package/dist/lib/environment.js +71 -0
- package/dist/lib/environment.js.map +1 -0
- package/dist/lib/filesystems/dirTree.d.ts +70 -0
- package/dist/lib/filesystems/dirTree.js +157 -0
- package/dist/lib/filesystems/dirTree.js.map +1 -0
- package/dist/lib/filesystems/local.d.ts +18 -8
- package/dist/lib/filesystems/local.js +166 -160
- package/dist/lib/filesystems/local.js.map +1 -1
- package/dist/lib/filesystems/remote.d.ts +12 -5
- package/dist/lib/filesystems/remote.js +226 -172
- package/dist/lib/filesystems/remote.js.map +1 -1
- package/dist/lib/ipc.js +1 -2
- package/dist/lib/ipc.js.map +1 -1
- package/dist/lib/lock.js +19 -12
- package/dist/lib/lock.js.map +1 -1
- package/dist/lib/logger.js +9 -7
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/state.js +159 -63
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/sync.d.ts +18 -0
- package/dist/lib/sync.js +165 -96
- package/dist/lib/sync.js.map +1 -1
- package/dist/lib/tasks.d.ts +7 -8
- package/dist/lib/tasks.js +38 -45
- package/dist/lib/tasks.js.map +1 -1
- package/dist/semaphore.d.ts +1 -0
- package/dist/semaphore.js +22 -5
- package/dist/semaphore.js.map +1 -1
- package/dist/utils.js +51 -35
- package/dist/utils.js.map +1 -1
- package/eslint.config.mjs +36 -0
- package/package.json +19 -15
- package/tests/bench/collapse.bench.ts +114 -0
- package/tests/bench/cycle.bench.ts +111 -0
- package/tests/bench/deltas.bench.ts +151 -0
- package/tests/bench/harness/fake-sync.ts +32 -0
- package/tests/bench/harness/measure.ts +276 -0
- package/tests/bench/harness/scale-world.ts +160 -0
- package/tests/bench/harness/trees.ts +275 -0
- package/tests/bench/local-scan.bench.ts +74 -0
- package/tests/bench/longrun.bench.ts +130 -0
- package/tests/bench/profile-incremental.ts +90 -0
- package/tests/bench/remote-build.bench.ts +104 -0
- package/tests/bench/render.ts +14 -0
- package/tests/bench/semaphore.bench.ts +79 -0
- package/tests/bench/state.bench.ts +85 -0
- package/tests/bench/tasks-dispatch.bench.ts +156 -0
- package/tests/conformance/virtual-fs.test.ts +213 -0
- package/tests/e2e/backup.e2e.test.ts +130 -0
- package/tests/e2e/confirm.e2e.test.ts +191 -0
- package/tests/e2e/conflict.e2e.test.ts +261 -0
- package/tests/e2e/edge.e2e.test.ts +339 -0
- package/tests/e2e/harness/account.ts +104 -0
- package/tests/e2e/harness/assert.ts +127 -0
- package/tests/e2e/harness/drive.ts +88 -0
- package/tests/e2e/harness/mutations.ts +249 -0
- package/tests/e2e/harness/world.ts +222 -0
- package/tests/e2e/ignore.e2e.test.ts +123 -0
- package/tests/e2e/lifecycle.e2e.test.ts +290 -0
- package/tests/e2e/modes.e2e.test.ts +215 -0
- package/tests/e2e/platform.e2e.test.ts +157 -0
- package/tests/e2e/property.e2e.test.ts +163 -0
- package/tests/e2e/races.e2e.test.ts +90 -0
- package/tests/e2e/regressions.e2e.test.ts +212 -0
- package/tests/e2e/resilience.e2e.test.ts +231 -0
- package/tests/e2e/special.e2e.test.ts +185 -0
- package/tests/e2e/state.e2e.test.ts +229 -0
- package/tests/e2e/sync.e2e.test.ts +222 -0
- package/tests/fakes/fake-cloud.test.ts +267 -0
- package/tests/fakes/fake-cloud.ts +1094 -0
- package/tests/fakes/virtual-fs.ts +354 -0
- package/tests/harness/known-bug.ts +17 -0
- package/tests/harness/mutations.ts +65 -0
- package/tests/harness/runner.ts +141 -0
- package/tests/harness/snapshot.ts +113 -0
- package/tests/harness/world.ts +187 -0
- package/tests/scenarios/a-baseline.test.ts +107 -0
- package/tests/scenarios/aa-races.test.ts +258 -0
- package/tests/scenarios/ab-mode-property.test.ts +189 -0
- package/tests/scenarios/ac-platform.test.ts +320 -0
- package/tests/scenarios/ad-unicode-normalization.test.ts +67 -0
- package/tests/scenarios/b-additions.test.ts +160 -0
- package/tests/scenarios/c-modifications.test.ts +194 -0
- package/tests/scenarios/d-deletions.test.ts +259 -0
- package/tests/scenarios/e-rename-move.test.ts +288 -0
- package/tests/scenarios/f-ignore-filter.test.ts +346 -0
- package/tests/scenarios/g-large-deletion.test.ts +277 -0
- package/tests/scenarios/h-resilience.test.ts +167 -0
- package/tests/scenarios/i-lifecycle.test.ts +353 -0
- package/tests/scenarios/j-state-cache.test.ts +264 -0
- package/tests/scenarios/k-scale.test.ts +202 -0
- package/tests/scenarios/l-property.test.ts +145 -0
- package/tests/scenarios/m-golden.test.ts +452 -0
- package/tests/scenarios/o-task-errors.test.ts +497 -0
- package/tests/scenarios/p-remote-originated.test.ts +306 -0
- package/tests/scenarios/q-cycle-lifecycle.test.ts +234 -0
- package/tests/scenarios/r-rename-stress.test.ts +208 -0
- package/tests/scenarios/s-upgrade-transition.test.ts +171 -0
- package/tests/scenarios/t-type-change.test.ts +144 -0
- package/tests/scenarios/u-mode-local-to-cloud.test.ts +347 -0
- package/tests/scenarios/v-mode-local-backup.test.ts +201 -0
- package/tests/scenarios/w-mode-cloud-to-local.test.ts +304 -0
- package/tests/scenarios/x-mode-cloud-backup.test.ts +201 -0
- package/tests/scenarios/y-conflict-matrix.test.ts +292 -0
- package/tests/scenarios/z-cross-ops.test.ts +285 -0
- package/tests/scenarios/zb-dir-rename-cross.test.ts +296 -0
- package/tests/scenarios/zc-crash-recovery.test.ts +189 -0
- package/tests/scenarios/zd-inode-reuse.test.ts +118 -0
- package/tests/scenarios/ze-move-into-new-dir.test.ts +130 -0
- package/tests/scenarios/zf-remote-change-unchanged-local.test.ts +81 -0
- package/tests/scenarios/zg-edit-during-scan.test.ts +68 -0
- package/tests/scenarios/zh-dir-delete-vs-child.test.ts +104 -0
- package/tests/scenarios/zi-smoke-test-outage.test.ts +78 -0
- package/tests/scenarios/zj-trash-cleanup.test.ts +133 -0
- package/tests/scenarios/zk-ignore-asymmetry.test.ts +150 -0
- package/tests/scenarios/zl-mode-atomicity.test.ts +104 -0
- package/tests/scenarios/zm-scan-concurrency.test.ts +78 -0
- package/tests/scenarios/zn-delta-ordering.test.ts +130 -0
- package/tests/scenarios/zo-download-temp-cleanup.test.ts +65 -0
- package/tests/unit/collapse-deltas.test.ts +276 -0
- package/tests/unit/dir-tree.test.ts +159 -0
- package/tests/unit/icloud.test.ts +115 -0
- package/tests/unit/ignorer-cache-regression.test.ts +70 -0
- package/tests/unit/ignorer.test.ts +63 -0
- package/tests/unit/ipc-lock.test.ts +438 -0
- package/tests/unit/lock.test.ts +135 -0
- package/tests/unit/n-unit.test.ts +632 -0
- package/tests/unit/remote-tree-unordered-regression.test.ts +101 -0
- package/tests/unit/semaphore-regression.test.ts +140 -0
- package/tests/unit/state-refencode-regression.test.ts +224 -0
- package/tests/unit/state.test.ts +809 -0
- package/tests/unit/tasks-dispatch-order-regression.test.ts +53 -0
- package/tests/unit/worker-api.test.ts +379 -0
- package/tsconfig.json +10 -1
- package/tsconfig.test.json +12 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.bench.config.ts +32 -0
- package/vitest.config.ts +27 -0
- package/vitest.e2e.config.ts +68 -0
- package/.eslintrc +0 -16
- package/jest.config.js +0 -5
package/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
24
|
package/dist/ignorer.d.ts
CHANGED
|
@@ -6,11 +6,17 @@ export declare class Ignorer {
|
|
|
6
6
|
instance: ignore.Ignore;
|
|
7
7
|
name: string;
|
|
8
8
|
private readonly mutex;
|
|
9
|
+
private lastAppliedContent;
|
|
9
10
|
constructor(sync: Sync, name?: string);
|
|
10
11
|
fetch(): Promise<string>;
|
|
11
12
|
write(content: string): Promise<void>;
|
|
12
13
|
clearFile(): Promise<void>;
|
|
13
14
|
initialize(passedContent?: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Rebuild the matcher from `rawContent` and reset the filesystem ignoredCaches so the next scan
|
|
17
|
+
* re-evaluates against the new rules. Records the content as the baseline for the unchanged-skip above.
|
|
18
|
+
*/
|
|
19
|
+
private applyContent;
|
|
14
20
|
update(content?: string): Promise<void>;
|
|
15
21
|
clear(): void;
|
|
16
22
|
ignores(path: string): boolean;
|
package/dist/ignorer.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Ignorer = exports.IGNORER_VERSION = void 0;
|
|
7
7
|
const ignore_1 = __importDefault(require("ignore"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const write_file_atomic_1 = __importDefault(require("write-file-atomic"));
|
|
11
9
|
const semaphore_1 = require("./semaphore");
|
|
12
10
|
exports.IGNORER_VERSION = 1;
|
|
13
11
|
class Ignorer {
|
|
@@ -15,6 +13,9 @@ class Ignorer {
|
|
|
15
13
|
this.instance = (0, ignore_1.default)();
|
|
16
14
|
this.name = "ignorer";
|
|
17
15
|
this.mutex = new semaphore_1.Semaphore(1);
|
|
16
|
+
// The exact ignore-rule content the current `instance` + the filesystem ignoredCaches reflect. Used to
|
|
17
|
+
// skip a needless cache wipe + matcher rebuild when a per-cycle re-init finds the rules unchanged.
|
|
18
|
+
this.lastAppliedContent = null;
|
|
18
19
|
this.sync = sync;
|
|
19
20
|
this.name = name;
|
|
20
21
|
}
|
|
@@ -24,19 +25,19 @@ class Ignorer {
|
|
|
24
25
|
const filePath = path_1.default.join(this.sync.dbPath, this.name, `v${exports.IGNORER_VERSION}`, this.sync.syncPair.uuid, "filenIgnore");
|
|
25
26
|
const physicalFilePath = path_1.default.join(this.sync.syncPair.localPath, ".filenignore");
|
|
26
27
|
let content = "";
|
|
27
|
-
const [exists, physicalExists] = await Promise.all([
|
|
28
|
+
const [exists, physicalExists] = await Promise.all([this.sync.environment.fs.exists(filePath), this.sync.environment.fs.exists(physicalFilePath)]);
|
|
28
29
|
if (exists) {
|
|
29
|
-
const stats = await
|
|
30
|
+
const stats = await this.sync.environment.fs.stat(filePath);
|
|
30
31
|
if (stats.size > 0) {
|
|
31
|
-
content += await
|
|
32
|
+
content += await this.sync.environment.fs.readFile(filePath, {
|
|
32
33
|
encoding: "utf-8"
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
if (physicalExists) {
|
|
37
|
-
const stats = await
|
|
38
|
+
const stats = await this.sync.environment.fs.stat(physicalFilePath);
|
|
38
39
|
if (stats.size > 0) {
|
|
39
|
-
content += `${content.length > 0 ? "\n" : ""}${await
|
|
40
|
+
content += `${content.length > 0 ? "\n" : ""}${await this.sync.environment.fs.readFile(physicalFilePath, {
|
|
40
41
|
encoding: "utf-8"
|
|
41
42
|
})}`;
|
|
42
43
|
}
|
|
@@ -51,8 +52,8 @@ class Ignorer {
|
|
|
51
52
|
await this.mutex.acquire();
|
|
52
53
|
try {
|
|
53
54
|
const filePath = path_1.default.join(this.sync.syncPair.localPath, ".filenignore");
|
|
54
|
-
await
|
|
55
|
-
await
|
|
55
|
+
await this.sync.environment.fs.ensureDir(path_1.default.dirname(filePath));
|
|
56
|
+
await this.sync.environment.writeFileAtomic(filePath, content, {
|
|
56
57
|
encoding: "utf-8"
|
|
57
58
|
});
|
|
58
59
|
}
|
|
@@ -65,14 +66,14 @@ class Ignorer {
|
|
|
65
66
|
try {
|
|
66
67
|
const filePath = path_1.default.join(this.sync.dbPath, this.name, `v${exports.IGNORER_VERSION}`, this.sync.syncPair.uuid, "filenIgnore");
|
|
67
68
|
const physicalFilePath = path_1.default.join(this.sync.syncPair.localPath, ".filenignore");
|
|
68
|
-
const [exists, physicalExists] = await Promise.all([
|
|
69
|
+
const [exists, physicalExists] = await Promise.all([this.sync.environment.fs.exists(filePath), this.sync.environment.fs.exists(physicalFilePath)]);
|
|
69
70
|
if (exists) {
|
|
70
|
-
await
|
|
71
|
+
await this.sync.environment.writeFileAtomic(filePath, "", {
|
|
71
72
|
encoding: "utf-8"
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
if (physicalExists) {
|
|
75
|
-
await
|
|
76
|
+
await this.sync.environment.writeFileAtomic(physicalFilePath, "", {
|
|
76
77
|
encoding: "utf-8"
|
|
77
78
|
});
|
|
78
79
|
}
|
|
@@ -82,22 +83,37 @@ class Ignorer {
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
async initialize(passedContent) {
|
|
85
|
-
this.sync.localFileSystem.ignoredCache.clear();
|
|
86
|
-
this.sync.remoteFileSystem.ignoredCache.clear();
|
|
87
|
-
let content = [];
|
|
88
86
|
if (typeof passedContent === "string") {
|
|
87
|
+
// Explicit content update: persist it, then always (re)build from it.
|
|
89
88
|
await this.write(passedContent);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.map(line => line.trim())
|
|
93
|
-
.filter(line => line.length > 0);
|
|
89
|
+
this.applyContent(passedContent);
|
|
90
|
+
return;
|
|
94
91
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
// Per-cycle re-init: the engine calls this EVERY cycle to pick up `.filenignore` edits. When the
|
|
93
|
+
// rules are byte-for-byte unchanged, the per-path ignore decisions are still valid — skip wiping the
|
|
94
|
+
// filesystem ignoredCaches. Clearing them forced every subsequent tree scan to recompute the
|
|
95
|
+
// expensive per-file ignore checks (micromatch + the gitignore matcher) for the WHOLE tree on every
|
|
96
|
+
// cycle, which dominated the incremental-change scan (the cache existed but was defeated each cycle).
|
|
97
|
+
// Only rebuild when the content actually changed. excludeDotFiles/mode changes invalidate the caches
|
|
98
|
+
// through their own update paths (index.ts), so this never serves a stale decision.
|
|
99
|
+
const rawContent = await this.fetch();
|
|
100
|
+
if (this.lastAppliedContent !== null && rawContent === this.lastAppliedContent) {
|
|
101
|
+
return;
|
|
100
102
|
}
|
|
103
|
+
this.applyContent(rawContent);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Rebuild the matcher from `rawContent` and reset the filesystem ignoredCaches so the next scan
|
|
107
|
+
* re-evaluates against the new rules. Records the content as the baseline for the unchanged-skip above.
|
|
108
|
+
*/
|
|
109
|
+
applyContent(rawContent) {
|
|
110
|
+
this.lastAppliedContent = rawContent;
|
|
111
|
+
this.sync.localFileSystem.ignoredCache.clear();
|
|
112
|
+
this.sync.remoteFileSystem.ignoredCache.clear();
|
|
113
|
+
const content = rawContent
|
|
114
|
+
.split("\n")
|
|
115
|
+
.map(line => line.trim())
|
|
116
|
+
.filter(line => line.length > 0);
|
|
101
117
|
this.instance = (0, ignore_1.default)();
|
|
102
118
|
if (content.length > 0) {
|
|
103
119
|
this.instance.add(content);
|
|
@@ -108,6 +124,9 @@ class Ignorer {
|
|
|
108
124
|
}
|
|
109
125
|
clear() {
|
|
110
126
|
this.instance = (0, ignore_1.default)();
|
|
127
|
+
// Invalidate the change-tracking baseline so the next initialize() rebuilds rather than skipping
|
|
128
|
+
// (otherwise a clear() followed by a same-content initialize() would leave the empty matcher in place).
|
|
129
|
+
this.lastAppliedContent = null;
|
|
111
130
|
}
|
|
112
131
|
ignores(path) {
|
|
113
132
|
const normalizedPath = path.startsWith("\\") ? path.slice(1) : path.startsWith("/") ? path.slice(1) : path;
|
package/dist/ignorer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignorer.js","sourceRoot":"","sources":["../src/ignorer.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAE3B,gDAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"ignorer.js","sourceRoot":"","sources":["../src/ignorer.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA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C,GAAG,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAAgB;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,QAAQ,GAAG,IAAA,gBAAM,GAAE,CAAA;QAExB,iGAAiG;QACjG,wGAAwG;QACxG,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAA;IAC/B,CAAC;IAEM,OAAO,CAAC,IAAY;QAC1B,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAE1G,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAA;QACb,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;QAEhD,OAAO,EAAE,CAAA;IACV,CAAC;CACD;AAhKD,0BAgKC;AAED,kBAAe,OAAO,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Sync from "./lib/sync";
|
|
|
3
3
|
import FilenSDK, { type FilenSDKConfig } from "@filen/sdk";
|
|
4
4
|
import { Semaphore } from "./semaphore";
|
|
5
5
|
import Logger from "./lib/logger";
|
|
6
|
+
import { type SyncEnvironment } from "./lib/environment";
|
|
6
7
|
/**
|
|
7
8
|
* SyncWorker
|
|
8
9
|
* @date 2/23/2024 - 5:50:56 AM
|
|
@@ -19,7 +20,8 @@ export declare class SyncWorker {
|
|
|
19
20
|
readonly sdk: FilenSDK;
|
|
20
21
|
readonly logger: Logger;
|
|
21
22
|
readonly runOnce: boolean;
|
|
22
|
-
|
|
23
|
+
readonly environment: SyncEnvironment;
|
|
24
|
+
constructor({ syncPairs, dbPath, sdkConfig, onMessage, runOnce, sdk, disableLogging, environment }: {
|
|
23
25
|
syncPairs: SyncPair[];
|
|
24
26
|
dbPath: string;
|
|
25
27
|
sdkConfig?: FilenSDKConfig;
|
|
@@ -27,6 +29,7 @@ export declare class SyncWorker {
|
|
|
27
29
|
runOnce?: boolean;
|
|
28
30
|
sdk?: FilenSDK;
|
|
29
31
|
disableLogging?: boolean;
|
|
32
|
+
environment?: SyncEnvironment;
|
|
30
33
|
});
|
|
31
34
|
resetCache(uuid: string): void;
|
|
32
35
|
resetTaskErrors(uuid: string): void;
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const sdk_1 = __importDefault(require("@filen/sdk"));
|
|
|
23
23
|
const semaphore_1 = require("./semaphore");
|
|
24
24
|
const constants_1 = require("./constants");
|
|
25
25
|
const logger_1 = __importDefault(require("./lib/logger"));
|
|
26
|
+
const environment_1 = require("./lib/environment");
|
|
26
27
|
/**
|
|
27
28
|
* SyncWorker
|
|
28
29
|
* @date 2/23/2024 - 5:50:56 AM
|
|
@@ -32,7 +33,7 @@ const logger_1 = __importDefault(require("./lib/logger"));
|
|
|
32
33
|
* @typedef {SyncWorker}
|
|
33
34
|
*/
|
|
34
35
|
class SyncWorker {
|
|
35
|
-
constructor({ syncPairs, dbPath, sdkConfig, onMessage, runOnce = false, sdk, disableLogging = false }) {
|
|
36
|
+
constructor({ syncPairs, dbPath, sdkConfig, onMessage, runOnce = false, sdk, disableLogging = false, environment }) {
|
|
36
37
|
this.syncs = {};
|
|
37
38
|
this.updateSyncPairsMutex = new semaphore_1.Semaphore(1);
|
|
38
39
|
if (!sdk && !sdkConfig) {
|
|
@@ -42,6 +43,7 @@ class SyncWorker {
|
|
|
42
43
|
process.onMessage = onMessage;
|
|
43
44
|
}
|
|
44
45
|
this.runOnce = runOnce;
|
|
46
|
+
this.environment = environment !== null && environment !== void 0 ? environment : (0, environment_1.defaultEnvironment)();
|
|
45
47
|
this.syncPairs = syncPairs;
|
|
46
48
|
this.dbPath = dbPath;
|
|
47
49
|
this.logger = new logger_1.default(disableLogging);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,sDAA6B;AAC7B,qDAA0D;AAC1D,2CAAuC;AACvC,2CAA2C;AAC3C,0DAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,sDAA6B;AAC7B,qDAA0D;AAC1D,2CAAuC;AACvC,2CAA2C;AAC3C,0DAAiC;AACjC,mDAA4E;AAE5E;;;;;;;GAOG;AACH,MAAa,UAAU;IAUtB,YAAmB,EAClB,SAAS,EACT,MAAM,EACN,SAAS,EACT,SAAS,EACT,OAAO,GAAG,KAAK,EACf,GAAG,EACH,cAAc,GAAG,KAAK,EACtB,WAAW,EAUX;QA1Be,UAAK,GAAyB,EAAE,CAAA;QAEhC,yBAAoB,GAAG,IAAI,qBAAS,CAAC,CAAC,CAAC,CAAA;QAyBtD,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;QAChF,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,SAAS,GAAG,SAAS,CAAA;QAC9B,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAA,gCAAkB,GAAE,CAAA;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI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AA;gBAEzD,MAAK;YACN,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,UAAU;QACtB,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC3C,CAAC;CACD;AA7VD,gCA6VC;AAED,0CAAuB;AACvB,kBAAe,UAAU,CAAA"}
|
package/dist/lib/deltas.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Sync from "./sync";
|
|
2
|
-
import { type
|
|
2
|
+
import { type SyncMode } from "../types";
|
|
3
|
+
import { type LocalTree, type LocalTreeError, type LocalTreeIgnored } from "./filesystems/local";
|
|
3
4
|
import { type RemoteTree } from "./filesystems/remote";
|
|
4
5
|
export type Delta = {
|
|
5
6
|
path: string;
|
|
@@ -39,6 +40,59 @@ export type Delta = {
|
|
|
39
40
|
from: string;
|
|
40
41
|
to: string;
|
|
41
42
|
});
|
|
43
|
+
export declare function collapseDeltas({ deltas, renamedLocalDirectories, renamedRemoteDirectories, deletedLocalDirectories, deletedRemoteDirectories }: {
|
|
44
|
+
deltas: Delta[];
|
|
45
|
+
renamedLocalDirectories: Delta[];
|
|
46
|
+
renamedRemoteDirectories: Delta[];
|
|
47
|
+
deletedLocalDirectories: Delta[];
|
|
48
|
+
deletedRemoteDirectories: Delta[];
|
|
49
|
+
}): Delta[];
|
|
50
|
+
/**
|
|
51
|
+
* Find directories slated for deletion that STILL hold live content on the deleting-resistant side — a
|
|
52
|
+
* freshly-added child, or a base child kept alive by newer-modify-wins — and must therefore survive.
|
|
53
|
+
*
|
|
54
|
+
* When one side deletes a directory and the other adds/keeps something inside it in the same cycle, the
|
|
55
|
+
* raw delta set contains both `deleteXDirectory <dir>` and the child's own add. Left alone, collapseDeltas
|
|
56
|
+
* subsumes the child's sibling DELETES under the dir-delete and the dir-delete then cascades over the
|
|
57
|
+
* surviving child at execution time — wiping a brand-new file before it is ever propagated (data loss).
|
|
58
|
+
* Newer content beats a delete (the same rule the per-file passes already apply), so the directory must
|
|
59
|
+
* stay: drop its delete and let the surviving child's own add re-assert it.
|
|
60
|
+
*
|
|
61
|
+
* A child "survives under <dir>" iff it is present in the current tree (`tree`), is NOT itself slated for
|
|
62
|
+
* deletion (same-direction `delete{File,Directory}`), and is NOT leaving via a rename — neither the child
|
|
63
|
+
* itself nor any ancestor is the `from` of a same-direction `rename{File,Directory}` (a renamed directory
|
|
64
|
+
* carries all its descendants out with it). Without the rename exclusion, a directory rename — which is
|
|
65
|
+
* emitted as "rename the children to the new path + delete the now-empty old directory" — would look like
|
|
66
|
+
* the old directory still has live children and never get deleted (its children are still at their old
|
|
67
|
+
* paths in this pre-rebase tree). Returns the set of dir paths to KEEP. Pure: the caller applies the
|
|
68
|
+
* pruning. Linear in tree size times depth; short-circuits when nothing is being deleted.
|
|
69
|
+
*/
|
|
70
|
+
export declare function directoriesWithSurvivingChildren(deltas: Delta[], dirDeleteType: "deleteLocalDirectory" | "deleteRemoteDirectory", fileDeleteType: "deleteLocalFile" | "deleteRemoteFile", renameDirType: "renameLocalDirectory" | "renameRemoteDirectory", renameFileType: "renameLocalFile" | "renameRemoteFile", tree: Record<string, unknown>): Set<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Remaps `path` across a set of propagated directory renames, returning its post-rename path (unchanged if
|
|
73
|
+
* none applies). The most-specific (longest `from`) ancestor wins, and each rename's `to` already encodes
|
|
74
|
+
* any outer renames (the rename pass records every directory's FINAL position), so one pass handles
|
|
75
|
+
* independent AND nested directory renames correctly.
|
|
76
|
+
*/
|
|
77
|
+
export declare function rebasePathAcrossRenames(path: string, renames: {
|
|
78
|
+
from: string;
|
|
79
|
+
to: string;
|
|
80
|
+
}[]): string;
|
|
81
|
+
/**
|
|
82
|
+
* Returns a COPY of `tree` with every DESCENDANT of a renamed directory moved to its post-rename path. The
|
|
83
|
+
* input is never mutated (entries outside any renamed subtree are shared by reference). The renamed
|
|
84
|
+
* directory nodes themselves are NOT moved here — they are handled via `pathsAdded` — only their children.
|
|
85
|
+
* Used to realign the base + the not-yet-renamed side so the per-descendant passes attribute change at the
|
|
86
|
+
* correct post-rename path (BUG-A / BUG-B).
|
|
87
|
+
*/
|
|
88
|
+
export declare function rebaseLocalTreeAcrossRenames(tree: LocalTree, renames: {
|
|
89
|
+
from: string;
|
|
90
|
+
to: string;
|
|
91
|
+
}[]): LocalTree;
|
|
92
|
+
export declare function rebaseRemoteTreeAcrossRenames(tree: RemoteTree, renames: {
|
|
93
|
+
from: string;
|
|
94
|
+
to: string;
|
|
95
|
+
}[]): RemoteTree;
|
|
42
96
|
/**
|
|
43
97
|
* Deltas
|
|
44
98
|
* @date 3/1/2024 - 11:11:32 PM
|
|
@@ -82,18 +136,20 @@ export declare class Deltas {
|
|
|
82
136
|
* deleteRemoteFileCountRaw: number
|
|
83
137
|
* }>}
|
|
84
138
|
*/
|
|
85
|
-
process({ currentLocalTree, currentRemoteTree, previousLocalTree, previousRemoteTree, currentLocalTreeErrors }: {
|
|
139
|
+
process({ currentLocalTree, currentRemoteTree, previousLocalTree, previousRemoteTree, currentLocalTreeErrors, currentLocalTreeIgnored }: {
|
|
86
140
|
currentLocalTree: LocalTree;
|
|
87
141
|
currentRemoteTree: RemoteTree;
|
|
88
142
|
previousLocalTree: LocalTree;
|
|
89
143
|
previousRemoteTree: RemoteTree;
|
|
90
144
|
currentLocalTreeErrors: LocalTreeError[];
|
|
145
|
+
currentLocalTreeIgnored: LocalTreeIgnored[];
|
|
91
146
|
}): Promise<{
|
|
92
147
|
deltas: Delta[];
|
|
93
148
|
deleteLocalDirectoryCountRaw: number;
|
|
94
149
|
deleteLocalFileCountRaw: number;
|
|
95
150
|
deleteRemoteDirectoryCountRaw: number;
|
|
96
151
|
deleteRemoteFileCountRaw: number;
|
|
152
|
+
mode: SyncMode;
|
|
97
153
|
}>;
|
|
98
154
|
}
|
|
99
155
|
export default Deltas;
|