@filen/sync 0.1.1 → 0.1.4
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/LICENSE +661 -661
- package/README.md +1 -1
- package/SECURITY.md +17 -17
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +51 -1
- package/dist/constants.js.map +1 -1
- package/dist/ignorer.d.ts +14 -0
- package/dist/ignorer.js +69 -0
- package/dist/ignorer.js.map +1 -0
- package/dist/index.d.ts +31 -17
- package/dist/index.js +125 -24
- package/dist/index.js.map +1 -1
- package/dist/lib/deltas.d.ts +9 -31
- package/dist/lib/deltas.js +194 -99
- package/dist/lib/deltas.js.map +1 -1
- package/dist/lib/filesystems/local.d.ts +32 -43
- package/dist/lib/filesystems/local.js +383 -106
- package/dist/lib/filesystems/local.js.map +1 -1
- package/dist/lib/filesystems/remote.d.ts +21 -7
- package/dist/lib/filesystems/remote.js +531 -67
- package/dist/lib/filesystems/remote.js.map +1 -1
- package/dist/lib/ipc.d.ts +9 -0
- package/dist/lib/ipc.js +60 -0
- package/dist/lib/ipc.js.map +1 -0
- package/dist/lib/lock.d.ts +13 -0
- package/dist/lib/lock.js +73 -0
- package/dist/lib/lock.js.map +1 -0
- package/dist/lib/logger.d.ts +14 -0
- package/dist/lib/logger.js +93 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/state.d.ts +4 -15
- package/dist/lib/state.js +106 -87
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/sync.d.ts +30 -10
- package/dist/lib/sync.js +363 -36
- package/dist/lib/sync.js.map +1 -1
- package/dist/lib/tasks.d.ts +27 -40
- package/dist/lib/tasks.js +397 -48
- package/dist/lib/tasks.js.map +1 -1
- package/dist/types.d.ts +340 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +164 -1
- package/dist/utils.js.map +1 -1
- package/index.d.ts +6 -295
- package/jest.config.js +5 -0
- package/package.json +62 -58
- package/tests/utils.test.ts +33 -0
- package/tsconfig.json +24 -24
package/dist/lib/sync.js
CHANGED
|
@@ -4,13 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Sync = void 0;
|
|
7
|
-
const sdk_1 = __importDefault(require("@filen/sdk"));
|
|
8
7
|
const constants_1 = require("../constants");
|
|
9
8
|
const local_1 = require("./filesystems/local");
|
|
10
9
|
const remote_1 = require("./filesystems/remote");
|
|
11
10
|
const deltas_1 = __importDefault(require("./deltas"));
|
|
12
11
|
const tasks_1 = __importDefault(require("./tasks"));
|
|
13
12
|
const state_1 = __importDefault(require("./state"));
|
|
13
|
+
const ipc_1 = require("./ipc");
|
|
14
|
+
const worker_threads_1 = require("worker_threads");
|
|
15
|
+
const ignorer_1 = __importDefault(require("../ignorer"));
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const lock_1 = __importDefault(require("./lock"));
|
|
14
18
|
/**
|
|
15
19
|
* Sync
|
|
16
20
|
*
|
|
@@ -24,24 +28,99 @@ class Sync {
|
|
|
24
28
|
*
|
|
25
29
|
* @constructor
|
|
26
30
|
* @public
|
|
27
|
-
* @param {{ syncPair: SyncPair;
|
|
31
|
+
* @param {{ syncPair: SyncPair; worker: SyncWorker }} param0
|
|
28
32
|
* @param {SyncPair} param0.syncPair
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {FilenSDKConfig} param0.sdkConfig
|
|
33
|
+
* @param {SyncWorker} param0.worker
|
|
31
34
|
*/
|
|
32
|
-
constructor({ syncPair,
|
|
35
|
+
constructor({ syncPair, worker }) {
|
|
33
36
|
this.isInitialized = false;
|
|
34
|
-
this.previousLocalTree = {
|
|
35
|
-
|
|
37
|
+
this.previousLocalTree = {
|
|
38
|
+
tree: {},
|
|
39
|
+
inodes: {}
|
|
40
|
+
};
|
|
41
|
+
this.previousRemoteTree = {
|
|
42
|
+
tree: {},
|
|
43
|
+
uuids: {}
|
|
44
|
+
};
|
|
36
45
|
this.localFileHashes = {};
|
|
46
|
+
this.abortControllers = {};
|
|
47
|
+
this.pauseSignals = {};
|
|
48
|
+
this.removed = false;
|
|
49
|
+
this.saveStateOnNoChanges = true;
|
|
50
|
+
this.taskErrors = [];
|
|
51
|
+
this.worker = worker;
|
|
37
52
|
this.syncPair = syncPair;
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
53
|
+
this.mode = syncPair.mode;
|
|
54
|
+
this.paused = syncPair.paused;
|
|
55
|
+
this.excludeDotFiles = syncPair.excludeDotFiles;
|
|
56
|
+
this.dbPath = worker.dbPath;
|
|
57
|
+
this.sdk = worker.sdk;
|
|
58
|
+
this.localFileSystem = new local_1.LocalFileSystem(this);
|
|
59
|
+
this.remoteFileSystem = new remote_1.RemoteFileSystem(this);
|
|
60
|
+
this.deltas = new deltas_1.default(this);
|
|
61
|
+
this.tasks = new tasks_1.default(this);
|
|
62
|
+
this.state = new state_1.default(this);
|
|
63
|
+
this.localIgnorer = new ignorer_1.default(this, "localIgnorer");
|
|
64
|
+
this.remoteIgnorer = new ignorer_1.default(this, "remoteIgnorer");
|
|
65
|
+
this.lock = new lock_1.default(this);
|
|
66
|
+
this.setupMainThreadListeners();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets up receiving message from the main thread.
|
|
70
|
+
*
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
setupMainThreadListeners() {
|
|
74
|
+
const receiver = !worker_threads_1.isMainThread && worker_threads_1.parentPort ? worker_threads_1.parentPort : process;
|
|
75
|
+
receiver.on("message", (message) => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
if (message.type === "stopTransfer" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
78
|
+
const abortController = this.abortControllers[`${message.data.of}:${message.data.relativePath}`];
|
|
79
|
+
if (!abortController || abortController.signal.aborted) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
abortController.abort();
|
|
83
|
+
}
|
|
84
|
+
else if (message.type === "pauseTransfer" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
85
|
+
const pauseSignal = this.pauseSignals[`${message.data.of}:${message.data.relativePath}`];
|
|
86
|
+
if (!pauseSignal || pauseSignal.isPaused()) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
pauseSignal.pause();
|
|
90
|
+
}
|
|
91
|
+
else if (message.type === "resumeTransfer" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
92
|
+
const pauseSignal = this.pauseSignals[`${message.data.of}:${message.data.relativePath}`];
|
|
93
|
+
if (!pauseSignal || !pauseSignal.isPaused()) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
pauseSignal.resume();
|
|
97
|
+
}
|
|
98
|
+
else if (message.type === "updateLocalIgnorer" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
99
|
+
this.localIgnorer.update((_a = message.data) === null || _a === void 0 ? void 0 : _a.content).catch(err => {
|
|
100
|
+
this.worker.logger.log("error", err, "sync.setupMainThreadListeners");
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (message.type === "updateRemoteIgnorer" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
104
|
+
this.remoteIgnorer.update((_b = message.data) === null || _b === void 0 ? void 0 : _b.content).catch(err => {
|
|
105
|
+
this.worker.logger.log("error", err, "sync.setupMainThreadListeners");
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else if (message.type === "pauseSyncPair" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
109
|
+
this.paused = true;
|
|
110
|
+
}
|
|
111
|
+
else if (message.type === "resumeSyncPair" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
112
|
+
this.paused = false;
|
|
113
|
+
}
|
|
114
|
+
else if (message.type === "changeSyncPairMode" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
115
|
+
this.mode = message.data.mode;
|
|
116
|
+
}
|
|
117
|
+
else if (message.type === "syncPairExcludeDotFiles" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
118
|
+
this.excludeDotFiles = true;
|
|
119
|
+
}
|
|
120
|
+
else if (message.type === "syncPairIncludeDotFiles" && message.syncPair.uuid === this.syncPair.uuid) {
|
|
121
|
+
this.excludeDotFiles = false;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
45
124
|
}
|
|
46
125
|
async initialize() {
|
|
47
126
|
if (this.isInitialized) {
|
|
@@ -49,48 +128,296 @@ class Sync {
|
|
|
49
128
|
}
|
|
50
129
|
this.isInitialized = true;
|
|
51
130
|
try {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
131
|
+
const [localSmokeTest, remoteSmokeTest] = await Promise.all([
|
|
132
|
+
this.localFileSystem.isPathWritable(this.syncPair.localPath),
|
|
133
|
+
this.remoteFileSystem.remoteDirPathExisting()
|
|
134
|
+
]);
|
|
135
|
+
if (!localSmokeTest || !remoteSmokeTest) {
|
|
136
|
+
throw new Error("Smoke tests failed. Either the local or remote path is not readable/writable");
|
|
137
|
+
}
|
|
138
|
+
await Promise.all([
|
|
139
|
+
this.localFileSystem.startDirectoryWatcher(),
|
|
140
|
+
this.state.initialize(),
|
|
141
|
+
this.localIgnorer.initialize(),
|
|
142
|
+
this.remoteIgnorer.initialize()
|
|
143
|
+
]);
|
|
55
144
|
this.run();
|
|
56
145
|
}
|
|
57
146
|
catch (e) {
|
|
147
|
+
this.worker.logger.log("error", e, "sync.initialize");
|
|
58
148
|
this.isInitialized = false;
|
|
59
149
|
throw e;
|
|
60
150
|
}
|
|
61
151
|
}
|
|
152
|
+
async cleanup() {
|
|
153
|
+
await this.localFileSystem.stopDirectoryWatcher();
|
|
154
|
+
this.isInitialized = false;
|
|
155
|
+
(0, ipc_1.postMessageToMain)({
|
|
156
|
+
type: "cycleExited",
|
|
157
|
+
syncPair: this.syncPair
|
|
158
|
+
});
|
|
159
|
+
}
|
|
62
160
|
async run() {
|
|
161
|
+
if (this.removed) {
|
|
162
|
+
(0, ipc_1.postMessageToMain)({
|
|
163
|
+
type: "syncPairRemoved",
|
|
164
|
+
syncPair: this.syncPair
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
63
168
|
try {
|
|
169
|
+
if (this.taskErrors.length > 0) {
|
|
170
|
+
if (this.worker.runOnce) {
|
|
171
|
+
await this.cleanup();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
(0, ipc_1.postMessageToMain)({
|
|
175
|
+
type: "doneTasks",
|
|
176
|
+
syncPair: this.syncPair,
|
|
177
|
+
data: {
|
|
178
|
+
tasks: [],
|
|
179
|
+
errors: this.taskErrors.map(e => (Object.assign(Object.assign({}, e), { error: (0, utils_1.serializeError)(e.error) })))
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
(0, ipc_1.postMessageToMain)({
|
|
183
|
+
type: "cycleRestarting",
|
|
184
|
+
syncPair: this.syncPair
|
|
185
|
+
});
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (this.paused) {
|
|
189
|
+
if (this.worker.runOnce) {
|
|
190
|
+
await this.cleanup();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
(0, ipc_1.postMessageToMain)({
|
|
194
|
+
type: "cyclePaused",
|
|
195
|
+
syncPair: this.syncPair
|
|
196
|
+
});
|
|
197
|
+
(0, ipc_1.postMessageToMain)({
|
|
198
|
+
type: "cycleRestarting",
|
|
199
|
+
syncPair: this.syncPair
|
|
200
|
+
});
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
(0, ipc_1.postMessageToMain)({
|
|
204
|
+
type: "cycleStarted",
|
|
205
|
+
syncPair: this.syncPair
|
|
206
|
+
});
|
|
207
|
+
const [localSmokeTest, remoteSmokeTest] = await Promise.all([
|
|
208
|
+
this.localFileSystem.isPathWritable(this.syncPair.localPath),
|
|
209
|
+
this.remoteFileSystem.remoteDirPathExisting()
|
|
210
|
+
]);
|
|
211
|
+
if (!localSmokeTest) {
|
|
212
|
+
if (this.worker.runOnce) {
|
|
213
|
+
await this.cleanup();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
(0, ipc_1.postMessageToMain)({
|
|
217
|
+
type: "cycleLocalSmokeTestFailed",
|
|
218
|
+
syncPair: this.syncPair,
|
|
219
|
+
data: {
|
|
220
|
+
error: (0, utils_1.serializeError)(new Error("Local path is not writable."))
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
(0, ipc_1.postMessageToMain)({
|
|
224
|
+
type: "cycleRestarting",
|
|
225
|
+
syncPair: this.syncPair
|
|
226
|
+
});
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!remoteSmokeTest) {
|
|
230
|
+
if (this.worker.runOnce) {
|
|
231
|
+
await this.cleanup();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
(0, ipc_1.postMessageToMain)({
|
|
235
|
+
type: "cycleLocalSmokeTestFailed",
|
|
236
|
+
syncPair: this.syncPair,
|
|
237
|
+
data: {
|
|
238
|
+
error: (0, utils_1.serializeError)(new Error("Remote path is not present or in the trash."))
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
(0, ipc_1.postMessageToMain)({
|
|
242
|
+
type: "cycleRestarting",
|
|
243
|
+
syncPair: this.syncPair
|
|
244
|
+
});
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
(0, ipc_1.postMessageToMain)({
|
|
248
|
+
type: "cycleWaitingForLocalDirectoryChangesStarted",
|
|
249
|
+
syncPair: this.syncPair
|
|
250
|
+
});
|
|
64
251
|
await this.localFileSystem.waitForLocalDirectoryChanges();
|
|
252
|
+
(0, ipc_1.postMessageToMain)({
|
|
253
|
+
type: "cycleWaitingForLocalDirectoryChangesDone",
|
|
254
|
+
syncPair: this.syncPair
|
|
255
|
+
});
|
|
256
|
+
(0, ipc_1.postMessageToMain)({
|
|
257
|
+
type: "cycleGettingTreesStarted",
|
|
258
|
+
syncPair: this.syncPair
|
|
259
|
+
});
|
|
260
|
+
// eslint-disable-next-line prefer-const
|
|
65
261
|
let [currentLocalTree, currentRemoteTree] = await Promise.all([
|
|
66
262
|
this.localFileSystem.getDirectoryTree(),
|
|
67
263
|
this.remoteFileSystem.getDirectoryTree()
|
|
68
264
|
]);
|
|
265
|
+
if (!currentLocalTree.changed && !currentRemoteTree.changed) {
|
|
266
|
+
if (this.taskErrors.length === 0) {
|
|
267
|
+
(0, ipc_1.postMessageToMain)({
|
|
268
|
+
type: "cycleSavingStateStarted",
|
|
269
|
+
syncPair: this.syncPair
|
|
270
|
+
});
|
|
271
|
+
this.previousLocalTree = currentLocalTree.result;
|
|
272
|
+
this.previousRemoteTree = currentRemoteTree.result;
|
|
273
|
+
// We only save the state once if there are no changes.
|
|
274
|
+
// This helps reducing the cpu and disk footprint when there are continuously no changes.
|
|
275
|
+
if (this.saveStateOnNoChanges) {
|
|
276
|
+
this.saveStateOnNoChanges = false;
|
|
277
|
+
await this.state.save();
|
|
278
|
+
}
|
|
279
|
+
(0, ipc_1.postMessageToMain)({
|
|
280
|
+
type: "cycleSavingStateDone",
|
|
281
|
+
syncPair: this.syncPair
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
(0, ipc_1.postMessageToMain)({
|
|
285
|
+
type: "cycleNoChanges",
|
|
286
|
+
syncPair: this.syncPair
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
(0, ipc_1.postMessageToMain)({
|
|
291
|
+
type: "cycleGettingTreesDone",
|
|
292
|
+
syncPair: this.syncPair
|
|
293
|
+
});
|
|
294
|
+
(0, ipc_1.postMessageToMain)({
|
|
295
|
+
type: "localTreeErrors",
|
|
296
|
+
syncPair: this.syncPair,
|
|
297
|
+
data: {
|
|
298
|
+
errors: currentLocalTree.errors.map(e => (Object.assign(Object.assign({}, e), { error: (0, utils_1.serializeError)(e.error) })))
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
(0, ipc_1.postMessageToMain)({
|
|
302
|
+
type: "localTreeIgnored",
|
|
303
|
+
syncPair: this.syncPair,
|
|
304
|
+
data: {
|
|
305
|
+
ignored: currentLocalTree.ignored
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
(0, ipc_1.postMessageToMain)({
|
|
309
|
+
type: "remoteTreeIgnored",
|
|
310
|
+
syncPair: this.syncPair,
|
|
311
|
+
data: {
|
|
312
|
+
ignored: currentRemoteTree.ignored
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
(0, ipc_1.postMessageToMain)({
|
|
316
|
+
type: "cycleProcessingDeltasStarted",
|
|
317
|
+
syncPair: this.syncPair
|
|
318
|
+
});
|
|
69
319
|
const deltas = await this.deltas.process({
|
|
70
|
-
currentLocalTree,
|
|
71
|
-
currentRemoteTree,
|
|
320
|
+
currentLocalTree: currentLocalTree.result,
|
|
321
|
+
currentRemoteTree: currentRemoteTree.result,
|
|
72
322
|
previousLocalTree: this.previousLocalTree,
|
|
73
|
-
previousRemoteTree: this.previousRemoteTree
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
323
|
+
previousRemoteTree: this.previousRemoteTree,
|
|
324
|
+
currentLocalTreeErrors: currentLocalTree.errors
|
|
325
|
+
});
|
|
326
|
+
(0, ipc_1.postMessageToMain)({
|
|
327
|
+
type: "cycleProcessingDeltasDone",
|
|
328
|
+
syncPair: this.syncPair
|
|
329
|
+
});
|
|
330
|
+
(0, ipc_1.postMessageToMain)({
|
|
331
|
+
type: "deltas",
|
|
332
|
+
syncPair: this.syncPair,
|
|
333
|
+
data: {
|
|
334
|
+
deltas
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
this.worker.logger.log("info", { deltas, localErrors: currentLocalTree.errors });
|
|
338
|
+
(0, ipc_1.postMessageToMain)({
|
|
339
|
+
type: "cycleProcessingTasksStarted",
|
|
340
|
+
syncPair: this.syncPair
|
|
341
|
+
});
|
|
342
|
+
const { doneTasks, errors } = await this.tasks.process({ deltas });
|
|
343
|
+
this.taskErrors = errors;
|
|
344
|
+
(0, ipc_1.postMessageToMain)({
|
|
345
|
+
type: "cycleProcessingTasksDone",
|
|
346
|
+
syncPair: this.syncPair
|
|
347
|
+
});
|
|
348
|
+
(0, ipc_1.postMessageToMain)({
|
|
349
|
+
type: "doneTasks",
|
|
350
|
+
syncPair: this.syncPair,
|
|
351
|
+
data: {
|
|
352
|
+
tasks: doneTasks.map(task => (Object.assign({ path: task.path, type: task.type }, (task.type === "uploadFile" ? { item: task.item } : {})))),
|
|
353
|
+
errors: this.taskErrors.map(e => (Object.assign(Object.assign({}, e), { error: (0, utils_1.serializeError)(e.error) })))
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
if (this.taskErrors.length === 0) {
|
|
357
|
+
if (doneTasks.length > 0) {
|
|
358
|
+
(0, ipc_1.postMessageToMain)({
|
|
359
|
+
type: "cycleApplyingStateStarted",
|
|
360
|
+
syncPair: this.syncPair
|
|
361
|
+
});
|
|
362
|
+
const applied = this.state.applyDoneTasksToState({
|
|
363
|
+
doneTasks,
|
|
364
|
+
currentLocalTree: currentLocalTree.result,
|
|
365
|
+
currentRemoteTree: currentRemoteTree.result
|
|
366
|
+
});
|
|
367
|
+
currentLocalTree.result = applied.currentLocalTree;
|
|
368
|
+
currentRemoteTree.result = applied.currentRemoteTree;
|
|
369
|
+
(0, ipc_1.postMessageToMain)({
|
|
370
|
+
type: "cycleApplyingStateDone",
|
|
371
|
+
syncPair: this.syncPair
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
(0, ipc_1.postMessageToMain)({
|
|
375
|
+
type: "cycleSavingStateStarted",
|
|
376
|
+
syncPair: this.syncPair
|
|
377
|
+
});
|
|
378
|
+
this.previousLocalTree = currentLocalTree.result;
|
|
379
|
+
this.previousRemoteTree = currentRemoteTree.result;
|
|
380
|
+
this.saveStateOnNoChanges = true;
|
|
381
|
+
await this.state.save();
|
|
382
|
+
(0, ipc_1.postMessageToMain)({
|
|
383
|
+
type: "cycleSavingStateDone",
|
|
384
|
+
syncPair: this.syncPair
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
(0, ipc_1.postMessageToMain)({
|
|
388
|
+
type: "cycleSuccess",
|
|
389
|
+
syncPair: this.syncPair
|
|
390
|
+
});
|
|
86
391
|
}
|
|
87
392
|
catch (e) {
|
|
88
|
-
|
|
393
|
+
this.worker.logger.log("error", e, "sync.run");
|
|
394
|
+
if (e instanceof Error) {
|
|
395
|
+
(0, ipc_1.postMessageToMain)({
|
|
396
|
+
type: "cycleError",
|
|
397
|
+
syncPair: this.syncPair,
|
|
398
|
+
data: {
|
|
399
|
+
error: (0, utils_1.serializeError)(e)
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
89
403
|
}
|
|
90
404
|
finally {
|
|
91
|
-
|
|
92
|
-
this.
|
|
93
|
-
}
|
|
405
|
+
if (this.worker.runOnce || this.removed) {
|
|
406
|
+
await this.cleanup();
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
(0, ipc_1.postMessageToMain)({
|
|
410
|
+
type: "cycleFinished",
|
|
411
|
+
syncPair: this.syncPair
|
|
412
|
+
});
|
|
413
|
+
(0, ipc_1.postMessageToMain)({
|
|
414
|
+
type: "cycleRestarting",
|
|
415
|
+
syncPair: this.syncPair
|
|
416
|
+
});
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
this.run();
|
|
419
|
+
}, constants_1.SYNC_INTERVAL);
|
|
420
|
+
}
|
|
94
421
|
}
|
|
95
422
|
}
|
|
96
423
|
}
|
package/dist/lib/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/lib/s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A,uBAAiB,EAAC;oBACjB,IAAI,EAAE,YAAY;oBAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,IAAI,EAAE;wBACL,KAAK,EAAE,IAAA,sBAAc,EAAC,CAAC,CAAC;qBACxB;iBACD,CAAC,CAAA;YACH,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACP,IAAA,uBAAiB,EAAC;oBACjB,IAAI,EAAE,eAAe;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACvB,CAAC,CAAA;gBAEF,IAAA,uBAAiB,EAAC;oBACjB,IAAI,EAAE,iBAAiB;oBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACvB,CAAC,CAAA;gBAEF,UAAU,CAAC,GAAG,EAAE;oBACf,IAAI,CAAC,GAAG,EAAE,CAAA;gBACX,CAAC,EAAE,yBAAa,CAAC,CAAA;YAClB,CAAC;QACF,CAAC;IACF,CAAC;CACD;AA/eD,oBA+eC;AAED,kBAAe,IAAI,CAAA"}
|
package/dist/lib/tasks.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type Sync from "./sync";
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
3
|
+
import { type Delta } from "./deltas";
|
|
4
|
+
import { type RemoteItem } from "./filesystems/remote";
|
|
5
5
|
import fs from "fs-extra";
|
|
6
|
+
export type TaskError = {
|
|
7
|
+
path: string;
|
|
8
|
+
error: Error;
|
|
9
|
+
type: "uploadFile" | "createRemoteDirectory" | "createLocalDirectory" | "deleteLocalFile" | "deleteRemoteFile" | "deleteLocalDirectory" | "deleteRemoteDirectory" | "downloadFile" | "renameLocalFile" | "renameRemoteFile" | "renameRemoteDirectory" | "renameLocalDirectory";
|
|
10
|
+
};
|
|
6
11
|
export type DoneTask = {
|
|
7
12
|
path: string;
|
|
8
13
|
} & ({
|
|
9
14
|
type: "uploadFile";
|
|
10
|
-
item:
|
|
15
|
+
item: RemoteItem;
|
|
16
|
+
stats: fs.Stats;
|
|
11
17
|
} | {
|
|
12
18
|
type: "createRemoteDirectory";
|
|
13
|
-
|
|
19
|
+
item: RemoteItem;
|
|
20
|
+
stats: fs.Stats;
|
|
14
21
|
} | {
|
|
15
22
|
type: "createLocalDirectory";
|
|
16
23
|
stats: fs.Stats;
|
|
24
|
+
item: RemoteItem;
|
|
17
25
|
} | {
|
|
18
26
|
type: "deleteLocalFile";
|
|
19
27
|
} | {
|
|
@@ -25,19 +33,12 @@ export type DoneTask = {
|
|
|
25
33
|
} | {
|
|
26
34
|
type: "downloadFile";
|
|
27
35
|
stats: fs.Stats;
|
|
28
|
-
|
|
29
|
-
type: "moveLocalFile";
|
|
30
|
-
from: string;
|
|
31
|
-
to: string;
|
|
36
|
+
item: RemoteItem;
|
|
32
37
|
} | {
|
|
33
38
|
type: "renameLocalFile";
|
|
34
39
|
from: string;
|
|
35
40
|
to: string;
|
|
36
41
|
stats: fs.Stats;
|
|
37
|
-
} | {
|
|
38
|
-
type: "moveRemoteFile";
|
|
39
|
-
from: string;
|
|
40
|
-
to: string;
|
|
41
42
|
} | {
|
|
42
43
|
type: "renameRemoteFile";
|
|
43
44
|
from: string;
|
|
@@ -51,20 +52,6 @@ export type DoneTask = {
|
|
|
51
52
|
from: string;
|
|
52
53
|
to: string;
|
|
53
54
|
stats: fs.Stats;
|
|
54
|
-
} | {
|
|
55
|
-
type: "moveRemoteDirectory";
|
|
56
|
-
from: string;
|
|
57
|
-
to: string;
|
|
58
|
-
} | {
|
|
59
|
-
type: "moveLocalFile";
|
|
60
|
-
from: string;
|
|
61
|
-
to: string;
|
|
62
|
-
stats: fs.Stats;
|
|
63
|
-
} | {
|
|
64
|
-
type: "moveLocalDirectory";
|
|
65
|
-
from: string;
|
|
66
|
-
to: string;
|
|
67
|
-
stats: fs.Stats;
|
|
68
55
|
});
|
|
69
56
|
/**
|
|
70
57
|
* Tasks
|
|
@@ -76,41 +63,41 @@ export type DoneTask = {
|
|
|
76
63
|
*/
|
|
77
64
|
export declare class Tasks {
|
|
78
65
|
private readonly sync;
|
|
66
|
+
private readonly transfersSemaphore;
|
|
79
67
|
/**
|
|
80
68
|
* Creates an instance of Tasks.
|
|
81
|
-
* @date 3/1/2024 - 11:11:36 PM
|
|
82
69
|
*
|
|
83
70
|
* @constructor
|
|
84
71
|
* @public
|
|
85
|
-
* @param {
|
|
86
|
-
* @param {Sync} param0.sync
|
|
72
|
+
* @param {Sync} sync
|
|
87
73
|
*/
|
|
88
|
-
constructor(
|
|
89
|
-
sync: Sync;
|
|
90
|
-
});
|
|
74
|
+
constructor(sync: Sync);
|
|
91
75
|
/**
|
|
92
|
-
* Process a task.
|
|
93
|
-
* @date 3/2/2024 - 12:14:48 PM
|
|
76
|
+
* Process a delta task.
|
|
94
77
|
*
|
|
95
78
|
* @private
|
|
96
79
|
* @async
|
|
97
|
-
* @param {
|
|
98
|
-
* @
|
|
99
|
-
* @returns {Promise<DoneTask>}
|
|
80
|
+
* @param {Delta} delta
|
|
81
|
+
* @returns {Promise<DoneTask | null>}
|
|
100
82
|
*/
|
|
101
83
|
private processTask;
|
|
102
84
|
/**
|
|
103
85
|
* Process all deltas.
|
|
104
|
-
* @date 3/5/2024 - 3:59:51 PM
|
|
105
86
|
*
|
|
106
87
|
* @public
|
|
107
88
|
* @async
|
|
108
89
|
* @param {{ deltas: Delta[] }} param0
|
|
109
90
|
* @param {{}} param0.deltas
|
|
110
|
-
* @returns {Promise<
|
|
91
|
+
* @returns {Promise<{
|
|
92
|
+
* doneTasks: DoneTask[]
|
|
93
|
+
* errors: TaskError[]
|
|
94
|
+
* }>}
|
|
111
95
|
*/
|
|
112
96
|
process({ deltas }: {
|
|
113
97
|
deltas: Delta[];
|
|
114
|
-
}): Promise<
|
|
98
|
+
}): Promise<{
|
|
99
|
+
doneTasks: DoneTask[];
|
|
100
|
+
errors: TaskError[];
|
|
101
|
+
}>;
|
|
115
102
|
}
|
|
116
103
|
export default Tasks;
|