core-3nweb-client-lib 0.53.17 → 0.53.20
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/build/api-defs/files.d.ts +6 -1
- package/build/core/asmail/delivery/index.js +3 -3
- package/build/core/asmail/delivery/per-recipient-wip.js +3 -2
- package/build/core/storage/local/obj-files.js +2 -1
- package/build/core/storage/synced/obj-files.d.ts +0 -1
- package/build/core/storage/synced/obj-files.js +1 -19
- package/build/core/storage/synced/upsyncer.d.ts +1 -0
- package/build/core/storage/synced/upsyncer.js +19 -14
- package/build/lib-client/request-utils.js +1 -1
- package/build/lib-client/xsp-fs/file.js +3 -1
- package/build/lib-client/xsp-fs/folder-node.d.ts +0 -1
- package/build/lib-client/xsp-fs/folder-node.js +38 -51
- package/build/lib-client/xsp-fs/fs.js +3 -1
- package/build/lib-client/xsp-fs/node-in-fs.d.ts +1 -1
- package/build/lib-client/xsp-fs/node-in-fs.js +5 -5
- package/build/lib-common/objs-on-disk/obj-version-file.js +1 -1
- package/build/lib-common-on-node/websocket-from-node.js +1 -1
- package/package.json +1 -1
|
@@ -1209,7 +1209,8 @@ declare namespace web3n.files {
|
|
|
1209
1209
|
syncStatus: ItemSyncStatus;
|
|
1210
1210
|
}
|
|
1211
1211
|
|
|
1212
|
-
type UploadEvent = UploadStartEvent | UploadProgressEvent |
|
|
1212
|
+
type UploadEvent = UploadStartEvent | UploadProgressEvent |
|
|
1213
|
+
UploadDisconnectedEvent | UploadErredEvent | UploadCancelledEvent | UploadDoneEvent;
|
|
1213
1214
|
|
|
1214
1215
|
interface UploadEventBase extends FSEvent {
|
|
1215
1216
|
uploadTaskId: number;
|
|
@@ -1238,6 +1239,10 @@ declare namespace web3n.files {
|
|
|
1238
1239
|
error: any;
|
|
1239
1240
|
}
|
|
1240
1241
|
|
|
1242
|
+
interface UploadCancelledEvent extends UploadEventBase {
|
|
1243
|
+
type: 'upload-cancelled';
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1241
1246
|
interface UploadDoneEvent extends UploadEventBase {
|
|
1242
1247
|
type: 'upload-done';
|
|
1243
1248
|
}
|
|
@@ -102,7 +102,6 @@ class Delivery {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
observeDelivery(id, observer) {
|
|
105
|
-
var _a;
|
|
106
105
|
const msg = this.msgs.get(id);
|
|
107
106
|
if (!msg) {
|
|
108
107
|
if (observer.error) {
|
|
@@ -111,8 +110,9 @@ class Delivery {
|
|
|
111
110
|
return () => { };
|
|
112
111
|
}
|
|
113
112
|
if (msg.isDone()) {
|
|
114
|
-
(
|
|
115
|
-
|
|
113
|
+
(0, sleep_1.sleep)(1)
|
|
114
|
+
.then(() => { var _a; return (_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, (0, json_utils_1.copy)(msg.progress)); })
|
|
115
|
+
.then(() => { var _a; return (_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); });
|
|
116
116
|
return () => { };
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2017, 2019 - 2021 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2017, 2019 - 2021, 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -118,11 +118,12 @@ class WIP {
|
|
|
118
118
|
async cancel() {
|
|
119
119
|
this.state.stage = "cancel";
|
|
120
120
|
return this.proc.startOrChain(async () => {
|
|
121
|
+
var _a;
|
|
121
122
|
if (this.state.stage === undefined) {
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
this.state.stage = undefined;
|
|
125
|
-
if (this.sender.sessionId) {
|
|
126
|
+
if ((_a = this.sender) === null || _a === void 0 ? void 0 : _a.sessionId) {
|
|
126
127
|
await this.sender.cancelDelivery();
|
|
127
128
|
}
|
|
128
129
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2020, 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2020, 2022, 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -139,6 +139,7 @@ class LocalObj {
|
|
|
139
139
|
throw new Error(`Version ${version} already exists in object ${this.objId}`);
|
|
140
140
|
}
|
|
141
141
|
const fPath = this.path(version);
|
|
142
|
+
// write$ process creates version file, and removes it when error happens
|
|
142
143
|
const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, undefined, this.objSegsGetterFromDisk);
|
|
143
144
|
try {
|
|
144
145
|
await (0, rxjs_1.lastValueFrom)(write$);
|
|
@@ -38,7 +38,6 @@ export declare class ObjFiles {
|
|
|
38
38
|
fileWrite$: Observable<FileWrite[]>;
|
|
39
39
|
newObj: SyncedObj;
|
|
40
40
|
}>;
|
|
41
|
-
findObjsToRemoveOnRemote(): Observable<ObjId>;
|
|
42
41
|
scheduleGC(obj: SyncedObj): void;
|
|
43
42
|
}
|
|
44
43
|
export type SynchronizerOnObjId = <T>(objId: ObjId, action: () => Promise<T>) => Promise<T>;
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.SyncedObj = exports.ObjFiles = exports.REMOTE_FILE_NAME_EXT = exports.UNSYNCED_FILE_NAME_EXT = void 0;
|
|
20
|
-
const rxjs_1 = require("rxjs");
|
|
21
20
|
const synced_1 = require("../../../lib-common/processes/synced");
|
|
22
21
|
const obj_folders_1 = require("../../../lib-client/objs-on-disk/obj-folders");
|
|
23
22
|
const fs = require("../../../lib-common/async-fs-node");
|
|
@@ -137,24 +136,6 @@ class ObjFiles {
|
|
|
137
136
|
.pipe((0, utils_for_observables_1.flatTap)(undefined, err => this.removeFailedNewObj(newObj)));
|
|
138
137
|
return { fileWrite$, newObj };
|
|
139
138
|
}
|
|
140
|
-
findObjsToRemoveOnRemote() {
|
|
141
|
-
return (0, rxjs_1.from)([undefined])
|
|
142
|
-
.pipe(
|
|
143
|
-
// listing recent folders, exactly once
|
|
144
|
-
(0, operators_1.mergeMap)(() => this.folders.listRecent()),
|
|
145
|
-
// flatten array and space it in time, to process folders one by one
|
|
146
|
-
(0, operators_1.mergeMap)(objsAndPaths => objsAndPaths), (0, operators_1.mergeMap)(async ({ objId, path }) => {
|
|
147
|
-
const obj = this.objs.get(objId);
|
|
148
|
-
if (obj) {
|
|
149
|
-
return (obj.statusObj().needsRemovalOnRemote() ?
|
|
150
|
-
objId : undefined);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const needsRm = await obj_status_1.ObjStatus.fileShowsObjNeedsRemovalOnRemote(path, objId);
|
|
154
|
-
return (needsRm ? objId : undefined);
|
|
155
|
-
}
|
|
156
|
-
}, 1), (0, operators_1.filter)(objId => (objId !== undefined)));
|
|
157
|
-
}
|
|
158
139
|
scheduleGC(obj) {
|
|
159
140
|
this.gc.scheduleCollection(obj);
|
|
160
141
|
}
|
|
@@ -293,6 +274,7 @@ class SyncedObj {
|
|
|
293
274
|
throw new Error(`Version ${version} already exists in object ${this.objId}`);
|
|
294
275
|
}
|
|
295
276
|
const fPath = this.localVerPath(version);
|
|
277
|
+
// write$ process creates version file, and removes it when error happens
|
|
296
278
|
const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, this.downloader, this.localAndSyncedObjSegsGetterFromDisk);
|
|
297
279
|
this.localVers.set(version, obj);
|
|
298
280
|
const fileWrite$ = write$.pipe((0, operators_1.tap)({
|
|
@@ -24,6 +24,7 @@ const obj_status_1 = require("./obj-status");
|
|
|
24
24
|
const deferred_1 = require("../../../lib-common/processes/deferred");
|
|
25
25
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
26
26
|
const synced_1 = require("../../../lib-common/processes/synced");
|
|
27
|
+
const error_1 = require("../../../lib-common/exceptions/error");
|
|
27
28
|
const MAX_CHUNK_SIZE = 512 * 1024;
|
|
28
29
|
const MAX_FAST_UPLOAD = 2 * 1024 * 1024;
|
|
29
30
|
class UpSyncer {
|
|
@@ -33,6 +34,11 @@ class UpSyncer {
|
|
|
33
34
|
this.tasksByObjIds = new Map();
|
|
34
35
|
this.tasksByIds = new Map();
|
|
35
36
|
this.syncedUploadStarts = new synced_1.NamedProcs();
|
|
37
|
+
this.removeTask = (task) => {
|
|
38
|
+
if (this.tasksByIds.delete(task.taskId)) {
|
|
39
|
+
this.tasksByObjIds.delete(task.objId);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
this.execPools = new labelled_exec_pools_1.LabelledExecPools([
|
|
37
43
|
{ label: 'long', maxProcs: 1 },
|
|
38
44
|
{ label: 'fast', maxProcs: 1 }
|
|
@@ -90,17 +96,11 @@ class UpSyncer {
|
|
|
90
96
|
if (localVersion > uploadVersion) {
|
|
91
97
|
await obj.removeLocalVersionFilesLessThan(localVersion);
|
|
92
98
|
}
|
|
93
|
-
});
|
|
99
|
+
}, this.removeTask);
|
|
94
100
|
this.tasksByIds.set(uploadTaskId, task);
|
|
95
101
|
this.tasksByObjIds.set(task.objId, task);
|
|
96
|
-
const completion = task.completion();
|
|
97
|
-
completion.finally(() => {
|
|
98
|
-
if (this.tasksByIds.delete(task.taskId)) {
|
|
99
|
-
this.tasksByObjIds.delete(task.objId);
|
|
100
|
-
}
|
|
101
|
-
}).catch(noop);
|
|
102
102
|
this.execPools.add(task);
|
|
103
|
-
return { completion, uploadTaskId };
|
|
103
|
+
return { completion: task.completion(), uploadTaskId };
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ exports.UpSyncer = UpSyncer;
|
|
|
108
108
|
Object.freeze(UpSyncer.prototype);
|
|
109
109
|
Object.freeze(UpSyncer);
|
|
110
110
|
class UploadTask {
|
|
111
|
-
constructor(taskId, remoteStorage, objId, objStatus, src, info, uploadHeader, doAtCompletion, eventSink, isRestart) {
|
|
111
|
+
constructor(taskId, remoteStorage, objId, objStatus, src, info, uploadHeader, doAtCompletion, rmTask, eventSink, isRestart) {
|
|
112
112
|
this.taskId = taskId;
|
|
113
113
|
this.remoteStorage = remoteStorage;
|
|
114
114
|
this.objId = objId;
|
|
@@ -117,6 +117,7 @@ class UploadTask {
|
|
|
117
117
|
this.info = info;
|
|
118
118
|
this.uploadHeader = uploadHeader;
|
|
119
119
|
this.doAtCompletion = doAtCompletion;
|
|
120
|
+
this.rmTask = rmTask;
|
|
120
121
|
this.eventSink = eventSink;
|
|
121
122
|
this.uploadCompletion = (0, deferred_1.defer)();
|
|
122
123
|
this.execLabel = executorLabelFor(this.info.needUpload);
|
|
@@ -124,14 +125,14 @@ class UploadTask {
|
|
|
124
125
|
this.emitUploadEvent('upload-started', { totalBytesToUpload: this.totalBytesToUpload, isRestart });
|
|
125
126
|
Object.seal(this);
|
|
126
127
|
}
|
|
127
|
-
static async for(obj, localVersion, uploadVersion, uploadHeader, syncedBase, createObj, taskId, eventSink, remoteStorage, doAtCompletion) {
|
|
128
|
+
static async for(obj, localVersion, uploadVersion, uploadHeader, syncedBase, createObj, taskId, eventSink, remoteStorage, doAtCompletion, rmTask) {
|
|
128
129
|
const src = await obj.getObjSrcFromLocalAndSyncedBranch(localVersion);
|
|
129
130
|
const objStatus = obj.statusObj();
|
|
130
131
|
if (objStatus.upload) {
|
|
131
132
|
const info = objStatus.upload;
|
|
132
133
|
if ((info.type === 'new-version')
|
|
133
134
|
&& (info.localVersion === localVersion) && (info.uploadVersion === uploadVersion)) {
|
|
134
|
-
return new UploadTask(taskId, remoteStorage, obj.objId, objStatus, src, info, uploadHeader, doAtCompletion, eventSink, true);
|
|
135
|
+
return new UploadTask(taskId, remoteStorage, obj.objId, objStatus, src, info, uploadHeader, doAtCompletion, rmTask, eventSink, true);
|
|
135
136
|
}
|
|
136
137
|
else {
|
|
137
138
|
let message;
|
|
@@ -164,7 +165,7 @@ class UploadTask {
|
|
|
164
165
|
needUpload
|
|
165
166
|
};
|
|
166
167
|
await objStatus.recordUploadStart(info);
|
|
167
|
-
return new UploadTask(taskId, remoteStorage, obj.objId, objStatus, src, info, uploadHeader, doAtCompletion, eventSink, false);
|
|
168
|
+
return new UploadTask(taskId, remoteStorage, obj.objId, objStatus, src, info, uploadHeader, doAtCompletion, rmTask, eventSink, false);
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
neededExecutor() {
|
|
@@ -220,6 +221,7 @@ class UploadTask {
|
|
|
220
221
|
else {
|
|
221
222
|
await this.doAtCompletion().finally(() => {
|
|
222
223
|
this.uploadCompletion.resolve();
|
|
224
|
+
this.rmTask(this);
|
|
223
225
|
this.emitUploadEvent('upload-done', {});
|
|
224
226
|
});
|
|
225
227
|
return true;
|
|
@@ -243,10 +245,11 @@ class UploadTask {
|
|
|
243
245
|
uploadVersion: this.info.uploadVersion,
|
|
244
246
|
cause: exc
|
|
245
247
|
}));
|
|
248
|
+
await this.objStatus.recordUploadCancellation(this.info);
|
|
249
|
+
this.rmTask(this);
|
|
246
250
|
this.emitUploadEvent('upload-erred', {
|
|
247
|
-
error: exc
|
|
251
|
+
error: (exc.runtimeException ? exc : (0, error_1.stringifyErr)(exc))
|
|
248
252
|
});
|
|
249
|
-
await this.objStatus.recordUploadCancellation(this.info);
|
|
250
253
|
return true;
|
|
251
254
|
}
|
|
252
255
|
}
|
|
@@ -350,6 +353,8 @@ class UploadTask {
|
|
|
350
353
|
await this.remoteStorage.cancelTransaction(this.objId, transactionId).catch(noop);
|
|
351
354
|
}
|
|
352
355
|
await this.objStatus.recordUploadCancellation(this.info).catch(noop);
|
|
356
|
+
this.rmTask(this);
|
|
357
|
+
this.emitUploadEvent('upload-cancelled', {});
|
|
353
358
|
}
|
|
354
359
|
}
|
|
355
360
|
Object.freeze(UploadTask.prototype);
|
|
@@ -81,7 +81,7 @@ async function attachRequestReaders(clReq, opts) {
|
|
|
81
81
|
// next tick occurs in between.
|
|
82
82
|
const response$ = (0, rxjs_1.fromEvent)(clReq, 'response', (res) => ({ res, resBodyPromise: readAllBytesFrom(res) }))
|
|
83
83
|
.pipe((0, operators_1.take)(1));
|
|
84
|
-
const err$ = (0, rxjs_1.fromEvent)(clReq, 'error', e => (0, http_1.makeConnectionException)(opts.url, opts.method, 'Cannot connect', e))
|
|
84
|
+
const err$ = (0, rxjs_1.merge)((0, rxjs_1.fromEvent)(clReq, 'error', e => (0, http_1.makeConnectionException)(opts.url, opts.method, 'Cannot connect', e)), (0, rxjs_1.fromEvent)(clReq, 'timeout', () => (0, http_1.makeConnectionException)(opts.url, opts.method, 'Cannot connect', TIMEOUT_FLAG)))
|
|
85
85
|
.pipe((0, operators_1.map)(exc => { throw exc; }), (0, operators_1.takeUntil)(response$));
|
|
86
86
|
try {
|
|
87
87
|
const reply = await (0, rxjs_1.lastValueFrom)((0, rxjs_1.merge)(response$, err$)
|
|
@@ -250,7 +250,8 @@ class S {
|
|
|
250
250
|
const node = await this.n.getNode();
|
|
251
251
|
const startedUpload = await node.startUpload(opts, true);
|
|
252
252
|
if (startedUpload) {
|
|
253
|
-
const { uploadTaskId, uploadVersion } = startedUpload;
|
|
253
|
+
const { uploadTaskId, uploadVersion, completion } = startedUpload;
|
|
254
|
+
completion.catch(noop);
|
|
254
255
|
return { uploadTaskId, uploadVersion };
|
|
255
256
|
}
|
|
256
257
|
else {
|
|
@@ -297,4 +298,5 @@ class S {
|
|
|
297
298
|
}
|
|
298
299
|
Object.freeze(S.prototype);
|
|
299
300
|
Object.freeze(S);
|
|
301
|
+
function noop() { }
|
|
300
302
|
Object.freeze(exports);
|
|
@@ -101,7 +101,6 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
|
|
|
101
101
|
getFolder(name: string, undefOnMissing?: boolean): Promise<FolderNode | undefined>;
|
|
102
102
|
getFile(name: string, undefOnMissing?: boolean): Promise<FileNode | undefined>;
|
|
103
103
|
getLink(name: string, undefOnMissing?: boolean): Promise<LinkNode | undefined>;
|
|
104
|
-
private fixMissingChildAndThrow;
|
|
105
104
|
/**
|
|
106
105
|
* If no initial local version given, then this performs like doTransition(change) method.
|
|
107
106
|
* When initial local version is given and check, exceptions are thrown if versions mismatch,
|
|
@@ -303,7 +303,17 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
303
303
|
throw (0, file_1.makeFileException)('notLink', childInfo.name);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
|
|
306
|
+
try {
|
|
307
|
+
return await this.getOrMakeChildNodeForInfo(childInfo);
|
|
308
|
+
}
|
|
309
|
+
catch (exc) {
|
|
310
|
+
if (undefOnMissing && exc.notFound) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
throw exc;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
307
317
|
}
|
|
308
318
|
async getOrMakeChildNodeForInfo(info, fromCurrentNodes = true) {
|
|
309
319
|
const { node, nodePromise } = this.storage.nodes.getNodeOrPromise(info.objId);
|
|
@@ -334,16 +344,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
334
344
|
exc = (0, file_1.makeFileException)('ioError', `${this.name}/${info.name}`, exc);
|
|
335
345
|
}
|
|
336
346
|
else if (exc.objNotFound) {
|
|
337
|
-
if (fromCurrentNodes) {
|
|
338
|
-
try {
|
|
339
|
-
await this.fixMissingChildAndThrow(exc, info);
|
|
340
|
-
}
|
|
341
|
-
catch (exc) {
|
|
342
|
-
deferred.reject(exc);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
+
if (!fromCurrentNodes) {
|
|
347
348
|
try {
|
|
348
349
|
const node = await this.getNonLocal(info);
|
|
349
350
|
if (node) {
|
|
@@ -395,19 +396,20 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
395
396
|
getLink(name, undefOnMissing = false) {
|
|
396
397
|
return this.getNode('link', name, undefOnMissing);
|
|
397
398
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
399
|
+
// XXX apparently this causes a problem on moves received on other devices via sync
|
|
400
|
+
// private async fixMissingChildAndThrow(exc: StorageException, childInfo: NodeInfo): Promise<never> {
|
|
401
|
+
// await this.doTransition(async (state, version) => {
|
|
402
|
+
// const presentChild = state.nodes[childInfo.name];
|
|
403
|
+
// if (!presentChild || (presentChild.objId !== childInfo.objId)) {
|
|
404
|
+
// return [];
|
|
405
|
+
// }
|
|
406
|
+
// delete state.nodes[childInfo.name];
|
|
407
|
+
// return this.makeEntryRemovalEvent(version, 'local', childInfo);
|
|
408
|
+
// }).catch(noop);
|
|
409
|
+
// const fileExc = makeFileException('notFound', childInfo.name, exc);
|
|
410
|
+
// fileExc.inconsistentStateOfFS = true;
|
|
411
|
+
// throw fileExc;
|
|
412
|
+
// }
|
|
411
413
|
/**
|
|
412
414
|
* If no initial local version given, then this performs like doTransition(change) method.
|
|
413
415
|
* When initial local version is given and check, exceptions are thrown if versions mismatch,
|
|
@@ -602,6 +604,8 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
602
604
|
this.callRemoveObjOn('local', f);
|
|
603
605
|
}
|
|
604
606
|
async removeChildEntryUnconditionally(name) {
|
|
607
|
+
// XXX this removal of record is done in presence of error, which may lead to non-accessible child obj.
|
|
608
|
+
// Should we label found inconsistency, so that it can be fixed later? Should we have lost&found?
|
|
605
609
|
await this.doTransition(async (state, version) => {
|
|
606
610
|
const child = state.nodes[name];
|
|
607
611
|
if (!child) {
|
|
@@ -1179,9 +1183,10 @@ function addToTransitionState(state, f, key) {
|
|
|
1179
1183
|
function diffNodes(current, remote, synced) {
|
|
1180
1184
|
const currentNodesById = orderByIds(current.nodes);
|
|
1181
1185
|
const syncedNodesById = orderByIds(synced.nodes);
|
|
1182
|
-
const
|
|
1186
|
+
const removedInLocal = [];
|
|
1183
1187
|
const renamed = [];
|
|
1184
|
-
const
|
|
1188
|
+
const addedInLocal = [];
|
|
1189
|
+
const addedInRemote = [];
|
|
1185
1190
|
const rekeyed = [];
|
|
1186
1191
|
const nameOverlaps = [];
|
|
1187
1192
|
for (const remoteNode of Object.values(remote.nodes)) {
|
|
@@ -1192,7 +1197,7 @@ function diffNodes(current, remote, synced) {
|
|
|
1192
1197
|
}
|
|
1193
1198
|
else {
|
|
1194
1199
|
const syncedNode = syncedNodesById.get(remoteNode.objId);
|
|
1195
|
-
(0, assert_1.assert)(!!
|
|
1200
|
+
(0, assert_1.assert)(!!syncedNode);
|
|
1196
1201
|
const localChanged = (syncedNode.name !== localNode.name);
|
|
1197
1202
|
const remoteChanged = (syncedNode.name !== remoteNode.name);
|
|
1198
1203
|
renamed.push({
|
|
@@ -1206,7 +1211,7 @@ function diffNodes(current, remote, synced) {
|
|
|
1206
1211
|
}
|
|
1207
1212
|
if (!(0, node_in_fs_1.areBytesEqual)(localNode.key, remoteNode.key)) {
|
|
1208
1213
|
const syncedNode = syncedNodesById.get(remoteNode.objId);
|
|
1209
|
-
(0, assert_1.assert)(!!
|
|
1214
|
+
(0, assert_1.assert)(!!syncedNode);
|
|
1210
1215
|
const localChanged = !(0, node_in_fs_1.areBytesEqual)(localNode.key, syncedNode.key);
|
|
1211
1216
|
const remoteChanged = !(0, node_in_fs_1.areBytesEqual)(localNode.key, syncedNode.key);
|
|
1212
1217
|
rekeyed.push({
|
|
@@ -1220,10 +1225,10 @@ function diffNodes(current, remote, synced) {
|
|
|
1220
1225
|
else {
|
|
1221
1226
|
const syncedNode = syncedNodesById.get(remoteNode.objId);
|
|
1222
1227
|
if (syncedNode) {
|
|
1223
|
-
|
|
1228
|
+
removedInLocal.push(remoteNode.name);
|
|
1224
1229
|
}
|
|
1225
1230
|
else {
|
|
1226
|
-
|
|
1231
|
+
addedInRemote.push(remoteNode.name);
|
|
1227
1232
|
}
|
|
1228
1233
|
if (current.nodes[remoteNode.name]) {
|
|
1229
1234
|
nameOverlaps.push(remoteNode.name);
|
|
@@ -1233,13 +1238,13 @@ function diffNodes(current, remote, synced) {
|
|
|
1233
1238
|
for (const localNode of currentNodesById.values()) {
|
|
1234
1239
|
const syncedNode = syncedNodesById.get(localNode.objId);
|
|
1235
1240
|
if (!syncedNode) {
|
|
1236
|
-
|
|
1241
|
+
addedInLocal.push(localNode.name);
|
|
1237
1242
|
}
|
|
1238
1243
|
}
|
|
1239
1244
|
return {
|
|
1240
|
-
removed:
|
|
1245
|
+
removed: { inLocal: removedInLocal },
|
|
1241
1246
|
renamed: ((renamed.length > 0) ? renamed : undefined),
|
|
1242
|
-
added:
|
|
1247
|
+
added: { inLocal: addedInLocal, inRemote: addedInRemote },
|
|
1243
1248
|
rekeyed: ((rekeyed.length > 0) ? rekeyed : undefined),
|
|
1244
1249
|
nameOverlaps: ((nameOverlaps.length > 0) ? nameOverlaps : undefined),
|
|
1245
1250
|
};
|
|
@@ -1282,22 +1287,4 @@ function identifyChanges(originalNodes, newNodes) {
|
|
|
1282
1287
|
}
|
|
1283
1288
|
return { addedNodes, removedNodes, renamedNodes };
|
|
1284
1289
|
}
|
|
1285
|
-
function reduceEmptyIn(c) {
|
|
1286
|
-
if (c.inLocal.length > 0) {
|
|
1287
|
-
if (c.inRemote.length > 0) {
|
|
1288
|
-
return c;
|
|
1289
|
-
}
|
|
1290
|
-
else {
|
|
1291
|
-
return { inLocal: c.inLocal };
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
else {
|
|
1295
|
-
if (c.inRemote.length > 0) {
|
|
1296
|
-
return { inRemote: c.inRemote };
|
|
1297
|
-
}
|
|
1298
|
-
else {
|
|
1299
|
-
return;
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
1290
|
Object.freeze(exports);
|
|
@@ -785,7 +785,8 @@ class S {
|
|
|
785
785
|
try {
|
|
786
786
|
const startedUpload = await node.startUpload(opts, true);
|
|
787
787
|
if (startedUpload) {
|
|
788
|
-
const { uploadTaskId, uploadVersion } = startedUpload;
|
|
788
|
+
const { uploadTaskId, uploadVersion, completion } = startedUpload;
|
|
789
|
+
completion.catch(noop);
|
|
789
790
|
return { uploadTaskId, uploadVersion };
|
|
790
791
|
}
|
|
791
792
|
else {
|
|
@@ -950,4 +951,5 @@ class S {
|
|
|
950
951
|
}
|
|
951
952
|
Object.freeze(S.prototype);
|
|
952
953
|
Object.freeze(S);
|
|
954
|
+
function noop() { }
|
|
953
955
|
Object.freeze(exports);
|
|
@@ -125,5 +125,5 @@ export declare abstract class NodeInFS<P extends NodePersistance> implements Nod
|
|
|
125
125
|
}
|
|
126
126
|
export declare function shouldReadCurrentVersion(flags: VersionedReadFlags | undefined): boolean;
|
|
127
127
|
export declare function areBytesEqual(b1: Uint8Array, b2: Uint8Array): boolean;
|
|
128
|
-
export declare function versionFromBranch(branch: SyncVersionsBranch, versionInBranch: number | undefined): number | undefined;
|
|
128
|
+
export declare function versionFromBranch(branch: SyncVersionsBranch, versionInBranch: number | undefined, fsItemName: string): number | undefined;
|
|
129
129
|
export {};
|
|
@@ -553,15 +553,15 @@ class NodeInFS {
|
|
|
553
553
|
let isCurrentLocal;
|
|
554
554
|
if (state === 'behind') {
|
|
555
555
|
isCurrentLocal = false;
|
|
556
|
-
remoteVersion = versionFromBranch(remote, remoteVersion);
|
|
556
|
+
remoteVersion = versionFromBranch(remote, remoteVersion, this.name);
|
|
557
557
|
}
|
|
558
558
|
else if (state === 'conflicting') {
|
|
559
559
|
isCurrentLocal = true;
|
|
560
|
-
remoteVersion = versionFromBranch(remote, remoteVersion);
|
|
560
|
+
remoteVersion = versionFromBranch(remote, remoteVersion, this.name);
|
|
561
561
|
}
|
|
562
562
|
else if (state === 'unsynced') {
|
|
563
563
|
isCurrentLocal = true;
|
|
564
|
-
remoteVersion = versionFromBranch(synced, remoteVersion);
|
|
564
|
+
remoteVersion = versionFromBranch(synced, remoteVersion, this.name);
|
|
565
565
|
}
|
|
566
566
|
else {
|
|
567
567
|
return;
|
|
@@ -716,12 +716,12 @@ function areBytesEqual(b1, b2) {
|
|
|
716
716
|
}
|
|
717
717
|
return true;
|
|
718
718
|
}
|
|
719
|
-
function versionFromBranch(branch, versionInBranch) {
|
|
719
|
+
function versionFromBranch(branch, versionInBranch, fsItemName) {
|
|
720
720
|
var _a;
|
|
721
721
|
if (versionInBranch) {
|
|
722
722
|
if ((versionInBranch !== branch.latest)
|
|
723
723
|
&& !((_a = branch.archived) === null || _a === void 0 ? void 0 : _a.includes(versionInBranch))) {
|
|
724
|
-
throw (0, exceptions_1.makeFSSyncException)(
|
|
724
|
+
throw (0, exceptions_1.makeFSSyncException)(fsItemName, {
|
|
725
725
|
versionMismatch: true,
|
|
726
726
|
message: `Unknown version in branch: ${versionInBranch}`
|
|
727
727
|
});
|
|
@@ -345,7 +345,7 @@ async function createNewV1File(path) {
|
|
|
345
345
|
const initContent = Buffer.alloc(v1_obj_file_format_1.V1_FILE_START.length + 8, 0);
|
|
346
346
|
initContent.set(v1_obj_file_format_1.V1_FILE_START);
|
|
347
347
|
// note that all 8 bytes of layout offset are zeros
|
|
348
|
-
await fs.writeFile(path, initContent, { flag: '
|
|
348
|
+
await fs.writeFile(path, initContent, { flag: 'w' });
|
|
349
349
|
}
|
|
350
350
|
async function recordLayoutOffsetInV1(fd, ofs) {
|
|
351
351
|
const ofsInBytes = Buffer.allocUnsafe(8);
|
|
@@ -167,7 +167,7 @@ function openSocketFromNode(url, sessionId, timeout, getAgent) {
|
|
|
167
167
|
ensureWebSocketUrlOK(url);
|
|
168
168
|
const headers = {};
|
|
169
169
|
headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
|
|
170
|
-
const ws = new WebSocket(url, { headers, agent: (_a = getAgent === null || getAgent === void 0 ? void 0 : getAgent()) !== null && _a !== void 0 ? _a : https_1.globalAgent, timeout });
|
|
170
|
+
const ws = new WebSocket(url, { headers, agent: (_a = getAgent === null || getAgent === void 0 ? void 0 : getAgent()) !== null && _a !== void 0 ? _a : https_1.globalAgent, handshakeTimeout: timeout });
|
|
171
171
|
let opening = (0, deferred_1.defer)();
|
|
172
172
|
const initOnError = (err) => {
|
|
173
173
|
opening === null || opening === void 0 ? void 0 : opening.reject((0, http_1.makeConnectionException)(url, undefined, `WebSocket connection error: ${err.message}`));
|