@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/deltas.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Deltas = void 0;
|
|
7
|
-
const
|
|
4
|
+
const utils_1 = require("../utils");
|
|
8
5
|
/**
|
|
9
6
|
* Deltas
|
|
10
7
|
* @date 3/1/2024 - 11:11:32 PM
|
|
@@ -16,19 +13,16 @@ const path_1 = __importDefault(require("path"));
|
|
|
16
13
|
class Deltas {
|
|
17
14
|
/**
|
|
18
15
|
* Creates an instance of Deltas.
|
|
19
|
-
* @date 3/1/2024 - 11:11:36 PM
|
|
20
16
|
*
|
|
21
17
|
* @constructor
|
|
22
18
|
* @public
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {Sync} param0.sync
|
|
19
|
+
* @param {Sync} sync
|
|
25
20
|
*/
|
|
26
|
-
constructor(
|
|
21
|
+
constructor(sync) {
|
|
27
22
|
this.sync = sync;
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Process the directory trees and return all sync deltas.
|
|
31
|
-
* @date 3/2/2024 - 8:42:25 AM
|
|
32
26
|
*
|
|
33
27
|
* @public
|
|
34
28
|
* @async
|
|
@@ -36,108 +30,105 @@ class Deltas {
|
|
|
36
30
|
* currentLocalTree: LocalTree
|
|
37
31
|
* currentRemoteTree: RemoteTree
|
|
38
32
|
* previousLocalTree: LocalTree
|
|
39
|
-
* previousRemoteTree: RemoteTree
|
|
33
|
+
* previousRemoteTree: RemoteTree,
|
|
34
|
+
* currentLocalTreeErrors: LocalTreeError[]
|
|
40
35
|
* }} param0
|
|
41
36
|
* @param {LocalTree} param0.currentLocalTree
|
|
42
37
|
* @param {RemoteTree} param0.currentRemoteTree
|
|
43
38
|
* @param {LocalTree} param0.previousLocalTree
|
|
44
39
|
* @param {RemoteTree} param0.previousRemoteTree
|
|
40
|
+
* @param {{}} param0.currentLocalTreeErrors
|
|
45
41
|
* @returns {Promise<Delta[]>}
|
|
46
42
|
*/
|
|
47
|
-
async process({ currentLocalTree, currentRemoteTree, previousLocalTree, previousRemoteTree }) {
|
|
48
|
-
|
|
43
|
+
async process({ currentLocalTree, currentRemoteTree, previousLocalTree, previousRemoteTree, currentLocalTreeErrors }) {
|
|
44
|
+
let deltas = [];
|
|
49
45
|
const pathsAdded = {};
|
|
46
|
+
const erroredLocalPaths = {};
|
|
47
|
+
const renamedRemoteDirectories = [];
|
|
48
|
+
const renamedLocalDirectories = [];
|
|
49
|
+
const deletedRemoteDirectories = [];
|
|
50
|
+
const deletedLocalDirectories = [];
|
|
51
|
+
for (const error of currentLocalTreeErrors) {
|
|
52
|
+
erroredLocalPaths[error.relativePath] = true;
|
|
53
|
+
}
|
|
54
|
+
// The order of delta processing:
|
|
55
|
+
// 1. Local directory/file move/rename
|
|
56
|
+
// 2. Remote directory/file move/rename
|
|
57
|
+
// 3. Local deletions
|
|
58
|
+
// 4. Remote deletions
|
|
59
|
+
// 5. Local additions/filemodifications
|
|
60
|
+
// 6. Remote additions/filemodifications
|
|
50
61
|
// Local file/directory move/rename
|
|
51
62
|
for (const inode in currentLocalTree.inodes) {
|
|
52
63
|
const currentItem = currentLocalTree.inodes[inode];
|
|
53
64
|
const previousItem = previousLocalTree.inodes[inode];
|
|
54
|
-
if (!currentItem ||
|
|
65
|
+
if (!currentItem ||
|
|
66
|
+
!previousItem ||
|
|
67
|
+
pathsAdded[currentItem.path] ||
|
|
68
|
+
pathsAdded[previousItem.path] ||
|
|
69
|
+
erroredLocalPaths[currentItem.path] ||
|
|
70
|
+
erroredLocalPaths[previousItem.path]) {
|
|
55
71
|
continue;
|
|
56
72
|
}
|
|
57
|
-
// Path from current item changed, it was either renamed or moved
|
|
58
|
-
if (currentItem.path !== previousItem.path) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const currentItemParent = currentLocalTree.tree[currentItemParentPath];
|
|
62
|
-
const previousItemParent = previousLocalTree.tree[previousItemParentPath];
|
|
63
|
-
const currentItemName = path_1.default.posix.basename(currentItem.path);
|
|
64
|
-
const previousItemName = path_1.default.posix.basename(previousItem.path);
|
|
65
|
-
// Names changed
|
|
66
|
-
if (currentItemName !== previousItemName) {
|
|
67
|
-
deltas.push({
|
|
68
|
-
type: currentItem.type === "directory" ? "renameRemoteDirectory" : "renameRemoteFile",
|
|
69
|
-
path: currentItem.path,
|
|
70
|
-
from: previousItem.path,
|
|
71
|
-
to: currentItem.path
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
pathsAdded[currentItem.path] = true;
|
|
75
|
-
pathsAdded[previousItem.path] = true;
|
|
76
|
-
// Parents did not change, continue
|
|
77
|
-
if ((currentItemParent === null || currentItemParent === void 0 ? void 0 : currentItemParent.inode) === (previousItemParent === null || previousItemParent === void 0 ? void 0 : previousItemParent.inode)) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
// Item was also moved
|
|
81
|
-
deltas.push({
|
|
82
|
-
type: currentItem.type === "directory" ? "moveRemoteDirectory" : "moveRemoteFile",
|
|
73
|
+
// Path from current item changed, it was either renamed or moved (same type)
|
|
74
|
+
if (currentItem.path !== previousItem.path && currentItem.type === previousItem.type) {
|
|
75
|
+
const delta = {
|
|
76
|
+
type: currentItem.type === "directory" ? "renameRemoteDirectory" : "renameRemoteFile",
|
|
83
77
|
path: currentItem.path,
|
|
84
78
|
from: previousItem.path,
|
|
85
79
|
to: currentItem.path
|
|
86
|
-
}
|
|
80
|
+
};
|
|
81
|
+
deltas.push(delta);
|
|
82
|
+
if (currentItem.type === "directory") {
|
|
83
|
+
renamedRemoteDirectories.push(delta);
|
|
84
|
+
}
|
|
85
|
+
pathsAdded[currentItem.path] = true;
|
|
86
|
+
pathsAdded[previousItem.path] = true;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
// Remote file/directory move/rename
|
|
90
90
|
for (const uuid in currentRemoteTree.uuids) {
|
|
91
91
|
const currentItem = currentRemoteTree.uuids[uuid];
|
|
92
|
-
const previousItem =
|
|
92
|
+
const previousItem = previousRemoteTree.uuids[uuid];
|
|
93
93
|
if (!currentItem || !previousItem || pathsAdded[currentItem.path] || pathsAdded[previousItem.path]) {
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
|
-
// Path from current item changed, it was either renamed or moved
|
|
97
|
-
if (currentItem.path !== previousItem.path) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const currentItemParent = currentRemoteTree.tree[currentItemParentPath];
|
|
101
|
-
const previousItemParent = previousRemoteTree.tree[previousItemParentPath];
|
|
102
|
-
const currentItemName = path_1.default.posix.basename(currentItem.path);
|
|
103
|
-
const previousItemName = path_1.default.posix.basename(previousItem.path);
|
|
104
|
-
// Names changed
|
|
105
|
-
if (currentItemName !== previousItemName) {
|
|
106
|
-
deltas.push({
|
|
107
|
-
type: currentItem.type === "directory" ? "renameRemoteDirectory" : "renameRemoteFile",
|
|
108
|
-
path: currentItem.path,
|
|
109
|
-
from: previousItem.path,
|
|
110
|
-
to: currentItem.path
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
pathsAdded[currentItem.path] = true;
|
|
114
|
-
pathsAdded[previousItem.path] = true;
|
|
115
|
-
// Parents did not change, continue
|
|
116
|
-
if ((currentItemParent === null || currentItemParent === void 0 ? void 0 : currentItemParent.uuid) === (previousItemParent === null || previousItemParent === void 0 ? void 0 : previousItemParent.uuid)) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
// Item was also moved
|
|
120
|
-
deltas.push({
|
|
121
|
-
type: currentItem.type === "directory" ? "moveRemoteDirectory" : "moveRemoteFile",
|
|
96
|
+
// Path from current item changed, it was either renamed or moved (same type)
|
|
97
|
+
if (currentItem.path !== previousItem.path && currentItem.type === previousItem.type) {
|
|
98
|
+
const delta = {
|
|
99
|
+
type: currentItem.type === "directory" ? "renameLocalDirectory" : "renameLocalFile",
|
|
122
100
|
path: currentItem.path,
|
|
123
101
|
from: previousItem.path,
|
|
124
102
|
to: currentItem.path
|
|
125
|
-
}
|
|
103
|
+
};
|
|
104
|
+
deltas.push(delta);
|
|
105
|
+
if (currentItem.type === "directory") {
|
|
106
|
+
renamedLocalDirectories.push(delta);
|
|
107
|
+
}
|
|
108
|
+
pathsAdded[currentItem.path] = true;
|
|
109
|
+
pathsAdded[previousItem.path] = true;
|
|
126
110
|
}
|
|
127
111
|
}
|
|
128
112
|
// Local deletions
|
|
129
113
|
for (const path in previousLocalTree.tree) {
|
|
130
|
-
if (pathsAdded[path]) {
|
|
114
|
+
if (pathsAdded[path] || erroredLocalPaths[path]) {
|
|
131
115
|
continue;
|
|
132
116
|
}
|
|
133
117
|
const previousLocalItem = previousLocalTree.tree[path];
|
|
134
118
|
const currentLocalItem = currentLocalTree.tree[path];
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
// If the item does not exist in the current tree but does in the previous one, it has been deleted.
|
|
120
|
+
// We also check if the previous inode does not exist in the current tree.
|
|
121
|
+
if (!currentLocalItem && previousLocalItem && !currentLocalTree.inodes[previousLocalItem.inode]) {
|
|
122
|
+
const delta = {
|
|
137
123
|
type: previousLocalItem.type === "directory" ? "deleteRemoteDirectory" : "deleteRemoteFile",
|
|
138
124
|
path
|
|
139
|
-
}
|
|
125
|
+
};
|
|
126
|
+
deltas.push(delta);
|
|
127
|
+
if (previousLocalItem.type === "directory") {
|
|
128
|
+
deletedRemoteDirectories.push(delta);
|
|
129
|
+
}
|
|
140
130
|
pathsAdded[path] = true;
|
|
131
|
+
pathsAdded[previousLocalItem.path] = true;
|
|
141
132
|
}
|
|
142
133
|
}
|
|
143
134
|
// Remote deletions
|
|
@@ -147,22 +138,31 @@ class Deltas {
|
|
|
147
138
|
}
|
|
148
139
|
const previousRemoteItem = previousRemoteTree.tree[path];
|
|
149
140
|
const currentRemoteItem = currentRemoteTree.tree[path];
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
// If the item does not exist in the current tree but does in the previous one, it has been deleted.
|
|
142
|
+
// We also check if the previous UUID does not exist in the current tree.
|
|
143
|
+
if (!currentRemoteItem && previousRemoteItem && !currentRemoteTree.uuids[previousRemoteItem.uuid]) {
|
|
144
|
+
const delta = {
|
|
152
145
|
type: previousRemoteItem.type === "directory" ? "deleteLocalDirectory" : "deleteLocalFile",
|
|
153
146
|
path
|
|
154
|
-
}
|
|
147
|
+
};
|
|
148
|
+
deltas.push(delta);
|
|
149
|
+
if (previousRemoteItem.type === "directory") {
|
|
150
|
+
deletedLocalDirectories.push(delta);
|
|
151
|
+
}
|
|
155
152
|
pathsAdded[path] = true;
|
|
153
|
+
pathsAdded[previousRemoteItem.path] = true;
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
|
-
// Local additions/
|
|
156
|
+
// Local additions/filemodifications
|
|
159
157
|
for (const path in currentLocalTree.tree) {
|
|
160
|
-
if (pathsAdded[path]) {
|
|
158
|
+
if (pathsAdded[path] || erroredLocalPaths[path]) {
|
|
161
159
|
continue;
|
|
162
160
|
}
|
|
163
161
|
const currentLocalItem = currentLocalTree.tree[path];
|
|
164
162
|
const currentRemoteItem = currentRemoteTree.tree[path];
|
|
165
|
-
|
|
163
|
+
// If the item does not exist in the current remote tree, but does in the local one, it should be uploaded.
|
|
164
|
+
// We also check if it in fact has existed before (the inode), if so, we skip it.
|
|
165
|
+
if (!currentRemoteItem && currentLocalItem && !previousLocalTree.inodes[currentLocalItem.inode]) {
|
|
166
166
|
deltas.push({
|
|
167
167
|
type: currentLocalItem.type === "directory" ? "createRemoteDirectory" : "uploadFile",
|
|
168
168
|
path
|
|
@@ -170,18 +170,20 @@ class Deltas {
|
|
|
170
170
|
pathsAdded[path] = true;
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
173
|
+
// If the item exists in both trees and has a different mod time + hash, we upload it again.
|
|
174
|
+
if (currentRemoteItem &&
|
|
175
|
+
currentRemoteItem.type === "file" &&
|
|
176
|
+
currentLocalItem &&
|
|
177
|
+
currentLocalItem.lastModified > currentRemoteItem.lastModified &&
|
|
178
|
+
(await this.sync.localFileSystem.createFileHash({
|
|
179
|
+
relativePath: path,
|
|
180
|
+
algorithm: "md5"
|
|
181
|
+
})) !== this.sync.localFileHashes[currentLocalItem.path]) {
|
|
182
|
+
deltas.push({
|
|
183
|
+
type: "uploadFile",
|
|
184
|
+
path
|
|
185
|
+
});
|
|
186
|
+
pathsAdded[path] = true;
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
189
|
// Remote additions/changes
|
|
@@ -191,7 +193,9 @@ class Deltas {
|
|
|
191
193
|
}
|
|
192
194
|
const currentLocalItem = currentLocalTree.tree[path];
|
|
193
195
|
const currentRemoteItem = currentRemoteTree.tree[path];
|
|
194
|
-
|
|
196
|
+
// If the item does not exist in the current local tree, but does in the remote one, it should be download.
|
|
197
|
+
// We also check if it in fact has existed before (the UUID), if so, we skip it.
|
|
198
|
+
if (!currentLocalItem && currentRemoteItem && !previousRemoteTree.uuids[currentRemoteItem.uuid]) {
|
|
195
199
|
deltas.push({
|
|
196
200
|
type: currentRemoteItem.type === "directory" ? "createLocalDirectory" : "downloadFile",
|
|
197
201
|
path
|
|
@@ -199,17 +203,108 @@ class Deltas {
|
|
|
199
203
|
pathsAdded[path] = true;
|
|
200
204
|
continue;
|
|
201
205
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
// If the item exists in both trees and the mod time changed, we download it.
|
|
207
|
+
if (currentRemoteItem &&
|
|
208
|
+
currentRemoteItem.type === "file" &&
|
|
209
|
+
currentLocalItem &&
|
|
210
|
+
currentRemoteItem.lastModified > currentLocalItem.lastModified) {
|
|
211
|
+
deltas.push({
|
|
212
|
+
type: "downloadFile",
|
|
213
|
+
path
|
|
214
|
+
});
|
|
215
|
+
pathsAdded[path] = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Filter deltas by sync mode
|
|
219
|
+
if (this.sync.mode === "localToCloud") {
|
|
220
|
+
deltas = deltas.filter(delta => delta.type === "createRemoteDirectory" ||
|
|
221
|
+
delta.type === "deleteRemoteDirectory" ||
|
|
222
|
+
delta.type === "deleteRemoteFile" ||
|
|
223
|
+
delta.type === "renameRemoteDirectory" ||
|
|
224
|
+
delta.type === "renameRemoteFile" ||
|
|
225
|
+
delta.type === "uploadFile");
|
|
226
|
+
}
|
|
227
|
+
if (this.sync.mode === "localBackup") {
|
|
228
|
+
deltas = deltas.filter(delta => delta.type === "createRemoteDirectory" ||
|
|
229
|
+
delta.type === "renameRemoteDirectory" ||
|
|
230
|
+
delta.type === "renameRemoteFile" ||
|
|
231
|
+
delta.type === "uploadFile");
|
|
232
|
+
}
|
|
233
|
+
if (this.sync.mode === "cloudToLocal") {
|
|
234
|
+
deltas = deltas.filter(delta => delta.type === "createLocalDirectory" ||
|
|
235
|
+
delta.type === "deleteLocalDirectory" ||
|
|
236
|
+
delta.type === "deleteLocalFile" ||
|
|
237
|
+
delta.type === "renameLocalDirectory" ||
|
|
238
|
+
delta.type === "renameLocalFile" ||
|
|
239
|
+
delta.type === "downloadFile");
|
|
240
|
+
}
|
|
241
|
+
if (this.sync.mode === "cloudBackup") {
|
|
242
|
+
deltas = deltas.filter(delta => delta.type === "createLocalDirectory" ||
|
|
243
|
+
delta.type === "renameLocalDirectory" ||
|
|
244
|
+
delta.type === "renameLocalFile" ||
|
|
245
|
+
delta.type === "downloadFile");
|
|
246
|
+
}
|
|
247
|
+
// Work on deltas from "left to right" (ascending order, path length).
|
|
248
|
+
const deltasSorted = deltas.sort((a, b) => a.path.split("/").length - b.path.split("/").length);
|
|
249
|
+
// Here we apply the done task to the delta state.
|
|
250
|
+
// E.g. when the user renames/moves a directory from "/sync/dir" to "/sync/dir2"
|
|
251
|
+
// we'll get all the rename/move deltas for the directory children aswell.
|
|
252
|
+
// This is pretty unecessary, hence we filter them here.
|
|
253
|
+
// Same for deletions. We only ever need to rename/move/delete the parent directory if the children did not change.
|
|
254
|
+
// This saves a lot of disk usage and API requests. This also saves time applying all done tasks to the overall state,
|
|
255
|
+
// since we need to loop through less doneTasks.
|
|
256
|
+
for (let i = 0; i < deltasSorted.length; i++) {
|
|
257
|
+
const delta = deltasSorted[i];
|
|
258
|
+
let moveUp = false;
|
|
259
|
+
if (delta.type === "renameLocalDirectory" || delta.type === "renameLocalFile") {
|
|
260
|
+
for (const directoryDelta of renamedLocalDirectories) {
|
|
261
|
+
if (directoryDelta.type === "renameLocalDirectory" && delta.from.startsWith(directoryDelta.from + "/")) {
|
|
262
|
+
const newFromPath = (0, utils_1.replacePathStartWithFromAndTo)(delta.from, directoryDelta.from, directoryDelta.to);
|
|
263
|
+
if (newFromPath === delta.to) {
|
|
264
|
+
deltasSorted.splice(i, 1);
|
|
265
|
+
moveUp = true;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
deltasSorted.splice(i, 1, Object.assign(Object.assign({}, delta), { from: newFromPath }));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
209
271
|
}
|
|
210
272
|
}
|
|
273
|
+
else if (delta.type === "renameRemoteDirectory" || delta.type === "renameRemoteFile") {
|
|
274
|
+
for (const directoryDelta of renamedRemoteDirectories) {
|
|
275
|
+
if (directoryDelta.type === "renameRemoteDirectory" && delta.from.startsWith(directoryDelta.from + "/")) {
|
|
276
|
+
const newFromPath = (0, utils_1.replacePathStartWithFromAndTo)(delta.from, directoryDelta.from, directoryDelta.to);
|
|
277
|
+
if (newFromPath === delta.to) {
|
|
278
|
+
deltasSorted.splice(i, 1);
|
|
279
|
+
moveUp = true;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
deltasSorted.splice(i, 1, Object.assign(Object.assign({}, delta), { from: newFromPath }));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else if (delta.type === "deleteLocalDirectory" || delta.type === "deleteLocalFile") {
|
|
288
|
+
for (const directoryDelta of deletedLocalDirectories) {
|
|
289
|
+
if (directoryDelta.type === "deleteLocalDirectory" && delta.path.startsWith(directoryDelta.path + "/")) {
|
|
290
|
+
deltasSorted.splice(i, 1);
|
|
291
|
+
moveUp = true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (delta.type === "deleteRemoteDirectory" || delta.type === "deleteRemoteFile") {
|
|
296
|
+
for (const directoryDelta of deletedRemoteDirectories) {
|
|
297
|
+
if (directoryDelta.type === "deleteRemoteDirectory" && delta.path.startsWith(directoryDelta.path + "/")) {
|
|
298
|
+
deltasSorted.splice(i, 1);
|
|
299
|
+
moveUp = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (moveUp) {
|
|
304
|
+
i--;
|
|
305
|
+
}
|
|
211
306
|
}
|
|
212
|
-
return
|
|
307
|
+
return deltasSorted;
|
|
213
308
|
}
|
|
214
309
|
}
|
|
215
310
|
exports.Deltas = Deltas;
|
package/dist/lib/deltas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltas.js","sourceRoot":"","sources":["../../src/lib/deltas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deltas.js","sourceRoot":"","sources":["../../src/lib/deltas.ts"],"names":[],"mappings":";;;AAGA,oCAAwD;AAiDxD;;;;;;;GAOG;AACH,MAAa,MAAM;IAGlB;;;;;;OAMG;IACH,YAAmB,IAAU;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,KAAK,CAAC,OAAO,CAAC,EACpB,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AC;YACF,CAAC;YAED,IAAI,MAAM,EAAE,CAAC;gBACZ,CAAC,EAAE,CAAA;YACJ,CAAC;QACF,CAAC;QAED,OAAO,YAAY,CAAA;IACpB,CAAC;CACD;AAxYD,wBAwYC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import type Sync from "../sync";
|
|
4
|
-
import type
|
|
4
|
+
import { type CloudItem } from "@filen/sdk";
|
|
5
5
|
export type LocalItem = {
|
|
6
6
|
lastModified: number;
|
|
7
7
|
type: "file" | "directory";
|
|
@@ -16,6 +16,16 @@ export type LocalTree = {
|
|
|
16
16
|
tree: LocalDirectoryTree;
|
|
17
17
|
inodes: LocalDirectoryINodes;
|
|
18
18
|
};
|
|
19
|
+
export type LocalTreeError = {
|
|
20
|
+
localPath: string;
|
|
21
|
+
relativePath: string;
|
|
22
|
+
error: Error;
|
|
23
|
+
};
|
|
24
|
+
export type LocalTreeIgnored = {
|
|
25
|
+
localPath: string;
|
|
26
|
+
relativePath: string;
|
|
27
|
+
reason: "dotFile" | "localIgnore" | "defaultIgnore" | "empty" | "symlink" | "invalidType";
|
|
28
|
+
};
|
|
19
29
|
/**
|
|
20
30
|
* LocalFileSystem
|
|
21
31
|
* @date 3/2/2024 - 12:38:22 PM
|
|
@@ -34,27 +44,23 @@ export declare class LocalFileSystem {
|
|
|
34
44
|
};
|
|
35
45
|
watcherRunning: boolean;
|
|
36
46
|
private watcherInstance;
|
|
47
|
+
readonly itemsMutex: import("../../semaphore").ISemaphore;
|
|
48
|
+
readonly mutex: import("../../semaphore").ISemaphore;
|
|
49
|
+
readonly mkdirMutex: import("../../semaphore").ISemaphore;
|
|
37
50
|
/**
|
|
38
51
|
* Creates an instance of LocalFileSystem.
|
|
39
|
-
* @date 3/2/2024 - 12:38:20 PM
|
|
40
52
|
*
|
|
41
53
|
* @constructor
|
|
42
54
|
* @public
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {Sync} param0.sync
|
|
55
|
+
* @param {Sync} sync
|
|
45
56
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* @public
|
|
54
|
-
* @async
|
|
55
|
-
* @returns {Promise<LocalTree>}
|
|
56
|
-
*/
|
|
57
|
-
getDirectoryTree(): Promise<LocalTree>;
|
|
57
|
+
constructor(sync: Sync);
|
|
58
|
+
getDirectoryTree(): Promise<{
|
|
59
|
+
result: LocalTree;
|
|
60
|
+
errors: LocalTreeError[];
|
|
61
|
+
ignored: LocalTreeIgnored[];
|
|
62
|
+
changed: boolean;
|
|
63
|
+
}>;
|
|
58
64
|
/**
|
|
59
65
|
* Start the local sync directory watcher.
|
|
60
66
|
* @date 3/2/2024 - 12:38:00 PM
|
|
@@ -87,18 +93,20 @@ export declare class LocalFileSystem {
|
|
|
87
93
|
waitForLocalDirectoryChanges(): Promise<void>;
|
|
88
94
|
/**
|
|
89
95
|
* Creates a hash of a file using streams.
|
|
90
|
-
* @date 3/2/2024 - 9:29:48 AM
|
|
91
96
|
*
|
|
92
97
|
* @public
|
|
93
98
|
* @async
|
|
94
|
-
* @param {{
|
|
99
|
+
* @param {{
|
|
100
|
+
* relativePath: string
|
|
101
|
+
* algorithm: "sha512" | "md5" | "sha256"
|
|
102
|
+
* }} param0
|
|
95
103
|
* @param {string} param0.relativePath
|
|
96
|
-
* @param {"sha512"} param0.algorithm
|
|
104
|
+
* @param {("sha512" | "md5" | "sha256")} param0.algorithm
|
|
97
105
|
* @returns {Promise<string>}
|
|
98
106
|
*/
|
|
99
107
|
createFileHash({ relativePath, algorithm }: {
|
|
100
108
|
relativePath: string;
|
|
101
|
-
algorithm: "sha512";
|
|
109
|
+
algorithm: "sha512" | "md5" | "sha256";
|
|
102
110
|
}): Promise<string>;
|
|
103
111
|
/**
|
|
104
112
|
* Create a directory inside the local sync path. Recursively creates intermediate directories if needed.
|
|
@@ -113,32 +121,10 @@ export declare class LocalFileSystem {
|
|
|
113
121
|
mkdir({ relativePath }: {
|
|
114
122
|
relativePath: string;
|
|
115
123
|
}): Promise<fs.Stats>;
|
|
116
|
-
/**
|
|
117
|
-
* Delete a file/directory inside the local sync path.
|
|
118
|
-
* @date 3/3/2024 - 10:05:55 PM
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
* @async
|
|
122
|
-
* @param {{ relativePath: string; permanent?: boolean }} param0
|
|
123
|
-
* @param {string} param0.relativePath
|
|
124
|
-
* @param {boolean} [param0.permanent=false]
|
|
125
|
-
* @returns {Promise<void>}
|
|
126
|
-
*/
|
|
127
124
|
unlink({ relativePath, permanent }: {
|
|
128
125
|
relativePath: string;
|
|
129
126
|
permanent?: boolean;
|
|
130
127
|
}): Promise<void>;
|
|
131
|
-
/**
|
|
132
|
-
* Rename a file/directory inside the local sync path. Recursively creates intermediate directories if needed.
|
|
133
|
-
* @date 3/2/2024 - 12:41:15 PM
|
|
134
|
-
*
|
|
135
|
-
* @public
|
|
136
|
-
* @async
|
|
137
|
-
* @param {{ fromRelativePath: string; toRelativePath: string }} param0
|
|
138
|
-
* @param {string} param0.fromRelativePath
|
|
139
|
-
* @param {string} param0.toRelativePath
|
|
140
|
-
* @returns {Promise<fs.Stats>}
|
|
141
|
-
*/
|
|
142
128
|
rename({ fromRelativePath, toRelativePath }: {
|
|
143
129
|
fromRelativePath: string;
|
|
144
130
|
toRelativePath: string;
|
|
@@ -151,10 +137,13 @@ export declare class LocalFileSystem {
|
|
|
151
137
|
* @async
|
|
152
138
|
* @param {{ relativePath: string }} param0
|
|
153
139
|
* @param {string} param0.relativePath
|
|
154
|
-
* @returns {Promise<
|
|
140
|
+
* @returns {Promise<CloudItem>}
|
|
155
141
|
*/
|
|
156
142
|
upload({ relativePath }: {
|
|
157
143
|
relativePath: string;
|
|
158
144
|
}): Promise<CloudItem>;
|
|
145
|
+
isPathWritable(path: string): Promise<boolean>;
|
|
146
|
+
isPathReadable(path: string): Promise<boolean>;
|
|
147
|
+
pathExists(path: string): Promise<boolean>;
|
|
159
148
|
}
|
|
160
149
|
export default LocalFileSystem;
|