@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.
Files changed (48) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +1 -1
  3. package/SECURITY.md +17 -17
  4. package/dist/constants.d.ts +7 -0
  5. package/dist/constants.js +51 -1
  6. package/dist/constants.js.map +1 -1
  7. package/dist/ignorer.d.ts +14 -0
  8. package/dist/ignorer.js +69 -0
  9. package/dist/ignorer.js.map +1 -0
  10. package/dist/index.d.ts +31 -17
  11. package/dist/index.js +125 -24
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/deltas.d.ts +9 -31
  14. package/dist/lib/deltas.js +194 -99
  15. package/dist/lib/deltas.js.map +1 -1
  16. package/dist/lib/filesystems/local.d.ts +32 -43
  17. package/dist/lib/filesystems/local.js +383 -106
  18. package/dist/lib/filesystems/local.js.map +1 -1
  19. package/dist/lib/filesystems/remote.d.ts +21 -7
  20. package/dist/lib/filesystems/remote.js +531 -67
  21. package/dist/lib/filesystems/remote.js.map +1 -1
  22. package/dist/lib/ipc.d.ts +9 -0
  23. package/dist/lib/ipc.js +60 -0
  24. package/dist/lib/ipc.js.map +1 -0
  25. package/dist/lib/lock.d.ts +13 -0
  26. package/dist/lib/lock.js +73 -0
  27. package/dist/lib/lock.js.map +1 -0
  28. package/dist/lib/logger.d.ts +14 -0
  29. package/dist/lib/logger.js +93 -0
  30. package/dist/lib/logger.js.map +1 -0
  31. package/dist/lib/state.d.ts +4 -15
  32. package/dist/lib/state.js +106 -87
  33. package/dist/lib/state.js.map +1 -1
  34. package/dist/lib/sync.d.ts +30 -10
  35. package/dist/lib/sync.js +363 -36
  36. package/dist/lib/sync.js.map +1 -1
  37. package/dist/lib/tasks.d.ts +27 -40
  38. package/dist/lib/tasks.js +397 -48
  39. package/dist/lib/tasks.js.map +1 -1
  40. package/dist/types.d.ts +340 -0
  41. package/dist/utils.d.ts +42 -0
  42. package/dist/utils.js +164 -1
  43. package/dist/utils.js.map +1 -1
  44. package/index.d.ts +6 -295
  45. package/jest.config.js +5 -0
  46. package/package.json +62 -58
  47. package/tests/utils.test.ts +33 -0
  48. package/tsconfig.json +24 -24
package/dist/types.d.ts CHANGED
@@ -1,12 +1,352 @@
1
+ import { type LocalTreeError, type LocalTreeIgnored } from "./lib/filesystems/local";
2
+ import { type Delta } from "./lib/deltas";
3
+ import { type DoneTask, type TaskError } from "./lib/tasks";
4
+ import { type RemoteTreeIgnored } from "./lib/filesystems/remote";
5
+ import { type SerializedError } from "./utils";
1
6
  export type SyncMode = "twoWay" | "localToCloud" | "localBackup" | "cloudToLocal" | "cloudBackup";
2
7
  export type SyncPair = {
8
+ name: string;
3
9
  uuid: string;
4
10
  localPath: string;
5
11
  remotePath: string;
6
12
  remoteParentUUID: string;
7
13
  mode: SyncMode;
14
+ excludeDotFiles: boolean;
15
+ paused: boolean;
8
16
  };
9
17
  export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
10
18
  export type Prettify<T> = {
11
19
  [K in keyof T]: T[K];
12
20
  } & {};
21
+ export type IPCDoneTask = Prettify<Omit<DoneTask, "stats">>;
22
+ export type IPCTaskError = Prettify<Omit<TaskError, "error"> & {
23
+ error: SerializedError;
24
+ }>;
25
+ export type IPCLocalTreeError = Prettify<Omit<LocalTreeError, "error"> & {
26
+ error: SerializedError;
27
+ }>;
28
+ export type CycleState = "cycleStarted" | "cycleFinished" | "cycleError" | "cycleSuccess" | "cycleWaitingForLocalDirectoryChangesStarted" | "cycleWaitingForLocalDirectoryChangesDone" | "cycleGettingTreesStarted" | "cycleGettingTreesDone" | "cycleProcessingDeltasStarted" | "cycleProcessingDeltasDone" | "cycleProcessingTasksStarted" | "cycleProcessingTasksDone" | "cycleApplyingStateStarted" | "cycleApplyingStateDone" | "cycleSavingStateStarted" | "cycleSavingStateDone" | "cycleRestarting" | "cyclePaused" | "cycleLocalSmokeTestFailed" | "cycleNoChanges" | "cycleRemoteSmokeTestFailed" | "cycleExited" | "cycleAcquiringLockStarted" | "cycleAcquiringLockDone" | "cycleReleasingLockStarted" | "cycleReleasingLockDone";
29
+ export type TransferData = {
30
+ of: "upload" | "download";
31
+ type: "progress";
32
+ relativePath: string;
33
+ localPath: string;
34
+ bytes: number;
35
+ size: number;
36
+ } | {
37
+ of: "upload" | "download";
38
+ type: "queued";
39
+ relativePath: string;
40
+ localPath: string;
41
+ size: number;
42
+ } | {
43
+ of: "upload" | "download";
44
+ type: "started";
45
+ relativePath: string;
46
+ localPath: string;
47
+ size: number;
48
+ } | {
49
+ of: "upload" | "download";
50
+ type: "finished";
51
+ relativePath: string;
52
+ localPath: string;
53
+ size: number;
54
+ } | {
55
+ of: "upload" | "download";
56
+ type: "error";
57
+ relativePath: string;
58
+ localPath: string;
59
+ error: SerializedError;
60
+ size: number;
61
+ } | {
62
+ of: "createLocalDirectory";
63
+ type: "error";
64
+ relativePath: string;
65
+ localPath: string;
66
+ error: SerializedError;
67
+ } | {
68
+ of: "createLocalDirectory";
69
+ type: "success";
70
+ relativePath: string;
71
+ localPath: string;
72
+ } | {
73
+ of: "createRemoteDirectory";
74
+ type: "error";
75
+ relativePath: string;
76
+ localPath: string;
77
+ error: SerializedError;
78
+ } | {
79
+ of: "createRemoteDirectory";
80
+ type: "success";
81
+ relativePath: string;
82
+ localPath: string;
83
+ } | {
84
+ of: "deleteLocalFile";
85
+ type: "error";
86
+ relativePath: string;
87
+ localPath: string;
88
+ error: SerializedError;
89
+ } | {
90
+ of: "deleteLocalFile";
91
+ type: "success";
92
+ relativePath: string;
93
+ localPath: string;
94
+ } | {
95
+ of: "deleteLocalDirectory";
96
+ type: "error";
97
+ relativePath: string;
98
+ localPath: string;
99
+ error: SerializedError;
100
+ } | {
101
+ of: "deleteLocalDirectory";
102
+ type: "success";
103
+ relativePath: string;
104
+ localPath: string;
105
+ } | {
106
+ of: "deleteRemoteFile";
107
+ type: "error";
108
+ relativePath: string;
109
+ localPath: string;
110
+ error: SerializedError;
111
+ } | {
112
+ of: "deleteRemoteFile";
113
+ type: "success";
114
+ relativePath: string;
115
+ localPath: string;
116
+ } | {
117
+ of: "deleteRemoteDirectory";
118
+ type: "error";
119
+ relativePath: string;
120
+ localPath: string;
121
+ error: SerializedError;
122
+ } | {
123
+ of: "deleteRemoteDirectory";
124
+ type: "success";
125
+ relativePath: string;
126
+ localPath: string;
127
+ } | {
128
+ of: "renameLocalFile";
129
+ type: "error";
130
+ relativePath: string;
131
+ localPath: string;
132
+ error: SerializedError;
133
+ } | {
134
+ of: "renameLocalFile";
135
+ type: "success";
136
+ relativePath: string;
137
+ localPath: string;
138
+ } | {
139
+ of: "renameLocalDirectory";
140
+ type: "error";
141
+ relativePath: string;
142
+ localPath: string;
143
+ error: SerializedError;
144
+ } | {
145
+ of: "renameLocalDirectory";
146
+ type: "success";
147
+ relativePath: string;
148
+ localPath: string;
149
+ } | {
150
+ of: "renameRemoteDirectory";
151
+ type: "error";
152
+ relativePath: string;
153
+ localPath: string;
154
+ error: SerializedError;
155
+ } | {
156
+ of: "renameRemoteDirectory";
157
+ type: "success";
158
+ relativePath: string;
159
+ localPath: string;
160
+ } | {
161
+ of: "renameRemoteFile";
162
+ type: "error";
163
+ relativePath: string;
164
+ localPath: string;
165
+ error: SerializedError;
166
+ } | {
167
+ of: "renameRemoteFile";
168
+ type: "success";
169
+ relativePath: string;
170
+ localPath: string;
171
+ } | {
172
+ of: "downloadFile";
173
+ type: "error";
174
+ relativePath: string;
175
+ localPath: string;
176
+ error: SerializedError;
177
+ } | {
178
+ of: "downloadFile";
179
+ type: "success";
180
+ relativePath: string;
181
+ localPath: string;
182
+ } | {
183
+ of: "uploadFile";
184
+ type: "error";
185
+ relativePath: string;
186
+ localPath: string;
187
+ error: SerializedError;
188
+ } | {
189
+ of: "uploadFile";
190
+ type: "success";
191
+ relativePath: string;
192
+ localPath: string;
193
+ };
194
+ export type SyncMessage = ({
195
+ syncPair: SyncPair;
196
+ } & ({
197
+ type: "transfer";
198
+ data: TransferData;
199
+ } | {
200
+ type: "localTreeErrors";
201
+ data: {
202
+ errors: IPCLocalTreeError[];
203
+ };
204
+ } | {
205
+ type: "localTreeIgnored";
206
+ data: {
207
+ ignored: LocalTreeIgnored[];
208
+ };
209
+ } | {
210
+ type: "remoteTreeIgnored";
211
+ data: {
212
+ ignored: RemoteTreeIgnored[];
213
+ };
214
+ } | {
215
+ type: "deltas";
216
+ data: {
217
+ deltas: Delta[];
218
+ };
219
+ } | {
220
+ type: "doneTasks";
221
+ data: {
222
+ tasks: IPCDoneTask[];
223
+ errors: IPCTaskError[];
224
+ };
225
+ } | {
226
+ type: "cycleStarted";
227
+ } | {
228
+ type: "cycleFinished";
229
+ } | {
230
+ type: "cycleError";
231
+ data: {
232
+ error: SerializedError;
233
+ };
234
+ } | {
235
+ type: "cycleSuccess";
236
+ } | {
237
+ type: "cycleExited";
238
+ } | {
239
+ type: "cycleWaitingForLocalDirectoryChangesStarted";
240
+ } | {
241
+ type: "cycleWaitingForLocalDirectoryChangesDone";
242
+ } | {
243
+ type: "cycleGettingTreesStarted";
244
+ } | {
245
+ type: "cycleGettingTreesDone";
246
+ } | {
247
+ type: "cycleProcessingDeltasStarted";
248
+ } | {
249
+ type: "cycleProcessingDeltasDone";
250
+ } | {
251
+ type: "cycleLocalSmokeTestFailed";
252
+ data: {
253
+ error: SerializedError;
254
+ };
255
+ } | {
256
+ type: "cycleRemoteSmokeTestFailed";
257
+ data: {
258
+ error: SerializedError;
259
+ };
260
+ } | {
261
+ type: "cycleNoChanges";
262
+ } | {
263
+ type: "cycleProcessingTasksStarted";
264
+ } | {
265
+ type: "cycleProcessingTasksDone";
266
+ } | {
267
+ type: "cycleApplyingStateStarted";
268
+ } | {
269
+ type: "cycleApplyingStateDone";
270
+ } | {
271
+ type: "cycleSavingStateStarted";
272
+ } | {
273
+ type: "cycleSavingStateDone";
274
+ } | {
275
+ type: "cycleRestarting";
276
+ } | {
277
+ type: "cycleAcquiringLockStarted";
278
+ } | {
279
+ type: "cycleAcquiringLockDone";
280
+ } | {
281
+ type: "cycleReleasingLockStarted";
282
+ } | {
283
+ type: "cycleReleasingLockDone";
284
+ } | {
285
+ type: "cyclePaused";
286
+ } | {
287
+ type: "stopTransfer";
288
+ data: {
289
+ of: "upload" | "download";
290
+ relativePath: string;
291
+ };
292
+ } | {
293
+ type: "pauseTransfer";
294
+ data: {
295
+ of: "upload" | "download";
296
+ relativePath: string;
297
+ };
298
+ } | {
299
+ type: "resumeTransfer";
300
+ data: {
301
+ of: "upload" | "download";
302
+ relativePath: string;
303
+ };
304
+ })) | {
305
+ type: "updateSyncPairs";
306
+ data: {
307
+ pairs: SyncPair[];
308
+ resetCache: boolean;
309
+ };
310
+ } | {
311
+ type: "error";
312
+ data: {
313
+ error: SerializedError;
314
+ };
315
+ } | {
316
+ type: "syncPairsUpdated";
317
+ } | {
318
+ type: "updateLocalIgnorer";
319
+ syncPair: SyncPair;
320
+ data?: {
321
+ content?: string;
322
+ };
323
+ } | {
324
+ type: "updateRemoteIgnorer";
325
+ syncPair: SyncPair;
326
+ data?: {
327
+ content?: string;
328
+ };
329
+ } | {
330
+ type: "resetSyncPairCache";
331
+ } | {
332
+ type: "pauseSyncPair";
333
+ syncPair: SyncPair;
334
+ } | {
335
+ type: "resumeSyncPair";
336
+ syncPair: SyncPair;
337
+ } | {
338
+ type: "changeSyncPairMode";
339
+ syncPair: SyncPair;
340
+ data: {
341
+ mode: SyncMode;
342
+ };
343
+ } | {
344
+ type: "syncPairExcludeDotFiles";
345
+ syncPair: SyncPair;
346
+ } | {
347
+ type: "syncPairIncludeDotFiles";
348
+ syncPair: SyncPair;
349
+ } | {
350
+ type: "syncPairRemoved";
351
+ syncPair: SyncPair;
352
+ };
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="lodash" />
1
2
  /**
2
3
  * Chunk large Promise.all executions.
3
4
  * @date 2/14/2024 - 11:59:34 PM
@@ -22,3 +23,44 @@ export declare function promiseAllChunked<T>(promises: Promise<T>[], chunkSize?:
22
23
  * @returns {Promise<T[]>}
23
24
  */
24
25
  export declare function promiseAllSettledChunked<T>(promises: Promise<T>[], chunkSize?: number): Promise<T[]>;
26
+ /**
27
+ * Convert a timestamp from seconds to milliseconds.
28
+ *
29
+ * @export
30
+ * @param {number} timestamp
31
+ * @returns {number}
32
+ */
33
+ export declare function convertTimestampToMs(timestamp: number): number;
34
+ export declare function isPathOverMaxLength(path: string): boolean;
35
+ export declare function isNameOverMaxLength(name: string): boolean;
36
+ export declare const isValidPath: ((path: string) => boolean) & import("lodash").MemoizedFunction;
37
+ export declare const isNameIgnoredByDefault: ((name: string) => boolean) & import("lodash").MemoizedFunction;
38
+ export declare const isRelativePathIgnoredByDefault: ((path: string) => boolean) & import("lodash").MemoizedFunction;
39
+ export declare const isSystemPathIgnoredByDefault: ((path: string) => boolean) & import("lodash").MemoizedFunction;
40
+ export declare const isDirectoryPathIgnoredByDefault: ((path: string) => boolean) & import("lodash").MemoizedFunction;
41
+ export type SerializedError = {
42
+ name: string;
43
+ message: string;
44
+ stack?: string;
45
+ stringified: string;
46
+ };
47
+ export declare function serializeError(error: Error): SerializedError;
48
+ export declare function deserializeError(serializedError: SerializedError): Error;
49
+ /**
50
+ * Replace a path with it's new parent path.
51
+ *
52
+ * @export
53
+ * @param {string} path
54
+ * @param {string} from
55
+ * @param {string} to
56
+ * @returns {string}
57
+ */
58
+ export declare function replacePathStartWithFromAndTo(path: string, from: string, to: string): string;
59
+ /**
60
+ * Check if a path includes a dot file.
61
+ *
62
+ * @export
63
+ * @param {string} path
64
+ * @returns {boolean}
65
+ */
66
+ export declare const pathIncludesDotFile: ((path: string) => boolean) & import("lodash").MemoizedFunction;
package/dist/utils.js CHANGED
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promiseAllSettledChunked = exports.promiseAllChunked = void 0;
6
+ exports.pathIncludesDotFile = exports.replacePathStartWithFromAndTo = exports.deserializeError = exports.serializeError = exports.isDirectoryPathIgnoredByDefault = exports.isSystemPathIgnoredByDefault = exports.isRelativePathIgnoredByDefault = exports.isNameIgnoredByDefault = exports.isValidPath = exports.isNameOverMaxLength = exports.isPathOverMaxLength = exports.convertTimestampToMs = exports.promiseAllSettledChunked = exports.promiseAllChunked = void 0;
7
+ const memoize_1 = __importDefault(require("lodash/memoize"));
8
+ const constants_1 = require("./constants");
9
+ const path_1 = __importDefault(require("path"));
4
10
  /**
5
11
  * Chunk large Promise.all executions.
6
12
  * @date 2/14/2024 - 11:59:34 PM
@@ -50,4 +56,161 @@ async function promiseAllSettledChunked(promises, chunkSize = 100000) {
50
56
  return results;
51
57
  }
52
58
  exports.promiseAllSettledChunked = promiseAllSettledChunked;
59
+ /**
60
+ * Convert a timestamp from seconds to milliseconds.
61
+ *
62
+ * @export
63
+ * @param {number} timestamp
64
+ * @returns {number}
65
+ */
66
+ function convertTimestampToMs(timestamp) {
67
+ const now = Date.now();
68
+ if (Math.abs(now - timestamp) < Math.abs(now - timestamp * 1000)) {
69
+ return timestamp;
70
+ }
71
+ return Math.floor(timestamp * 1000);
72
+ }
73
+ exports.convertTimestampToMs = convertTimestampToMs;
74
+ function isPathOverMaxLength(path) {
75
+ if (process.platform === "linux") {
76
+ return path.length + 1 > 4096;
77
+ }
78
+ else if (process.platform === "darwin") {
79
+ return path.length + 1 > 1024;
80
+ }
81
+ else if (process.platform === "win32") {
82
+ return path.length + 1 > 260;
83
+ }
84
+ return path.length + 1 > 260;
85
+ }
86
+ exports.isPathOverMaxLength = isPathOverMaxLength;
87
+ function isNameOverMaxLength(name) {
88
+ if (process.platform === "linux") {
89
+ return name.length + 1 > 255;
90
+ }
91
+ else if (process.platform === "darwin") {
92
+ return name.length + 1 > 255;
93
+ }
94
+ else if (process.platform === "win32") {
95
+ return name.length + 1 > 255;
96
+ }
97
+ return name.length + 1 > 255;
98
+ }
99
+ exports.isNameOverMaxLength = isNameOverMaxLength;
100
+ exports.isValidPath = (0, memoize_1.default)((path) => {
101
+ const illegalCharsWindows = /[<>:"/\\|?*]|^(?:aux|con|clock\$|nul|prn|com[1-9]|lpt[1-9])$/i;
102
+ const illegalCharsMacOS = /[:]/i;
103
+ const illegalCharsLinux = /[\0/]/i;
104
+ switch (process.platform) {
105
+ case "win32": {
106
+ return illegalCharsWindows.test(path);
107
+ }
108
+ case "darwin": {
109
+ return illegalCharsMacOS.test(path);
110
+ }
111
+ case "linux": {
112
+ return illegalCharsLinux.test(path);
113
+ }
114
+ default: {
115
+ return false;
116
+ }
117
+ }
118
+ });
119
+ exports.isNameIgnoredByDefault = (0, memoize_1.default)((name) => {
120
+ const nameLowercase = name.toLowerCase();
121
+ const extension = path_1.default.extname(name);
122
+ const extensionLowercase = extension.toLowerCase();
123
+ if (name.length === 0 ||
124
+ name.startsWith(" ") ||
125
+ name.endsWith(" ") ||
126
+ name.includes("\n") ||
127
+ name.includes("\r") ||
128
+ nameLowercase.startsWith(".~lock.") ||
129
+ nameLowercase.startsWith(".~lock") ||
130
+ nameLowercase.startsWith("~$") ||
131
+ constants_1.DEFAULT_IGNORED.extensions.includes(extensionLowercase) ||
132
+ constants_1.DEFAULT_IGNORED.names.includes(nameLowercase)) {
133
+ return true;
134
+ }
135
+ return false;
136
+ });
137
+ exports.isRelativePathIgnoredByDefault = (0, memoize_1.default)((path) => {
138
+ if ((0, exports.isNameIgnoredByDefault)(path_1.default.basename(path))) {
139
+ return true;
140
+ }
141
+ return path.split("/").some(part => part.length > 0 && (0, exports.isNameIgnoredByDefault)(part));
142
+ });
143
+ exports.isSystemPathIgnoredByDefault = (0, memoize_1.default)((path) => {
144
+ for (const systemPath of constants_1.DEFAULT_IGNORED.system) {
145
+ if (path.toLowerCase().includes(systemPath.toLowerCase())) {
146
+ return true;
147
+ }
148
+ }
149
+ return false;
150
+ });
151
+ exports.isDirectoryPathIgnoredByDefault = (0, memoize_1.default)((path) => {
152
+ for (const directoryPath of constants_1.DEFAULT_IGNORED.directories) {
153
+ if (path.toLowerCase().includes(directoryPath.toLowerCase())) {
154
+ return true;
155
+ }
156
+ }
157
+ return false;
158
+ });
159
+ function serializeError(error) {
160
+ return {
161
+ name: error.name,
162
+ message: error.message,
163
+ stack: error.stack,
164
+ stringified: `${error.name}: ${error.message}`
165
+ };
166
+ }
167
+ exports.serializeError = serializeError;
168
+ function deserializeError(serializedError) {
169
+ const error = new Error(serializedError.message);
170
+ error.name = serializedError.name;
171
+ error.stack = serializedError.stack;
172
+ return error;
173
+ }
174
+ exports.deserializeError = deserializeError;
175
+ /**
176
+ * Replace a path with it's new parent path.
177
+ *
178
+ * @export
179
+ * @param {string} path
180
+ * @param {string} from
181
+ * @param {string} to
182
+ * @returns {string}
183
+ */
184
+ function replacePathStartWithFromAndTo(path, from, to) {
185
+ if (path.endsWith("/")) {
186
+ path = path.slice(0, path.length - 1);
187
+ }
188
+ if (from.endsWith("/")) {
189
+ from = from.slice(0, from.length - 1);
190
+ }
191
+ if (to.endsWith("/")) {
192
+ to = to.slice(0, to.length - 1);
193
+ }
194
+ if (!path.startsWith("/")) {
195
+ path = `/${path}`;
196
+ }
197
+ if (!from.startsWith("/")) {
198
+ from = `/${from}`;
199
+ }
200
+ if (!to.startsWith("/")) {
201
+ to = `/${to}`;
202
+ }
203
+ return `${to}${path.slice(from.length)}`;
204
+ }
205
+ exports.replacePathStartWithFromAndTo = replacePathStartWithFromAndTo;
206
+ /**
207
+ * Check if a path includes a dot file.
208
+ *
209
+ * @export
210
+ * @param {string} path
211
+ * @returns {boolean}
212
+ */
213
+ exports.pathIncludesDotFile = (0, memoize_1.default)((path) => {
214
+ return path.split("/").some(part => part.length > 0 && part.trimStart().startsWith("."));
215
+ });
53
216
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src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