core-3nweb-client-lib 0.53.19 → 0.53.21

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.
@@ -995,7 +995,7 @@ declare namespace web3n.files {
995
995
  move(src: string, dst: string): Promise<void>;
996
996
 
997
997
  /**
998
- * This returns a promise, resolvable when file has been copied.
998
+ * This returns a promise, resolvable when file's contenet has been copied.
999
999
  * @param src is an initial path of a file
1000
1000
  * @param dst is a path of a file
1001
1001
  * @param overwrite is a flag that with a true value allows
@@ -1019,7 +1019,16 @@ declare namespace web3n.files {
1019
1019
  ): Promise<void>;
1020
1020
 
1021
1021
  /**
1022
- * This returns a promise, resolvable when file has been saved.
1022
+ * This returns a promise, resolvable when source item's xattrs are copied
1023
+ * to destination item
1024
+ * @param src is source item
1025
+ * @param dst is destination item
1026
+ * @param filter is a
1027
+ */
1028
+ copyXAttrs(src: string, dst: string, filter?: string[]): Promise<void>;
1029
+
1030
+ /**
1031
+ * This returns a promise, resolvable when file's content has been saved.
1023
1032
  * @param file is a file to save
1024
1033
  * @param dst is a path where to save given file
1025
1034
  * @param overwrite is a flag that with a true value allows
@@ -1209,7 +1218,8 @@ declare namespace web3n.files {
1209
1218
  syncStatus: ItemSyncStatus;
1210
1219
  }
1211
1220
 
1212
- type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDisconnectedEvent | UploadErredEvent | UploadDoneEvent;
1221
+ type UploadEvent = UploadStartEvent | UploadProgressEvent |
1222
+ UploadDisconnectedEvent | UploadErredEvent | UploadCancelledEvent | UploadDoneEvent;
1213
1223
 
1214
1224
  interface UploadEventBase extends FSEvent {
1215
1225
  uploadTaskId: number;
@@ -1238,6 +1248,10 @@ declare namespace web3n.files {
1238
1248
  error: any;
1239
1249
  }
1240
1250
 
1251
+ interface UploadCancelledEvent extends UploadEventBase {
1252
+ type: 'upload-cancelled';
1253
+ }
1254
+
1241
1255
  interface UploadDoneEvent extends UploadEventBase {
1242
1256
  type: 'upload-done';
1243
1257
  }
@@ -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
- (_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, (0, json_utils_1.copy)(msg.progress));
115
- (0, sleep_1.sleep)(1).then(() => { var _a; return (_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); });
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
  });
@@ -113,6 +113,7 @@ class InboxEvents {
113
113
  }
114
114
  resumeNetworkActivity() {
115
115
  if (this.listening.proc) {
116
+ this.listening.stop();
116
117
  this.listening.startWith(this.listening.proc.completion.then(() => this.subscribeToEventSrcAndPassHeartbeats()));
117
118
  }
118
119
  else {
@@ -152,6 +152,7 @@ class RemoteEvents {
152
152
  }
153
153
  resumeNetworkActivity() {
154
154
  if (this.listening.proc) {
155
+ this.listening.stop();
155
156
  this.listening.startWith(this.listening.proc.completion.then(() => this.subscribeToEventSrcAndPassHeartbeats()));
156
157
  }
157
158
  else {
@@ -21,6 +21,7 @@ export declare class UpSyncer {
21
21
  completion: Promise<void>;
22
22
  uploadTaskId: number;
23
23
  }>;
24
+ private removeTask;
24
25
  }
25
26
  export interface UploadStatusRecorder {
26
27
  recordUploadStart(info: NewVersionUpload): Promise<void>;
@@ -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).catch(noop);
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,14 @@ 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.uploadCompletion.reject((0, exceptions_1.makeFSSyncException)(`obj-upload`, {
357
+ message: `Upload cancelled`,
358
+ localVersion: this.info.localVersion,
359
+ uploadVersion: this.info.uploadVersion,
360
+ cause: `Upload canacelled`
361
+ }));
362
+ this.rmTask(this);
363
+ this.emitUploadEvent('upload-cancelled', {});
353
364
  }
354
365
  }
355
366
  Object.freeze(UploadTask.prototype);
@@ -61,6 +61,7 @@ function makeFSCaller(caller, fsMsg) {
61
61
  if (fsMsg.writable) {
62
62
  fs.copyFile = copyFile.makeCaller(caller, objPath);
63
63
  fs.copyFolder = copyFolder.makeCaller(caller, objPath);
64
+ fs.copyXAttrs = copyXAttrs.makeCaller(caller, objPath);
64
65
  fs.deleteFile = deleteFile.makeCaller(caller, objPath);
65
66
  fs.deleteFolder = deleteFolder.makeCaller(caller, objPath);
66
67
  fs.deleteLink = deleteLink.makeCaller(caller, objPath);
@@ -149,6 +150,7 @@ function exposeFSService(fs, expServices) {
149
150
  if (fs.writable) {
150
151
  implExp.copyFile = copyFile.wrapService(fs.copyFile);
151
152
  implExp.copyFolder = copyFolder.wrapService(fs.copyFolder);
153
+ implExp.copyXAttrs = copyXAttrs.wrapService(fs.copyXAttrs);
152
154
  implExp.deleteFile = deleteFile.wrapService(fs.deleteFile);
153
155
  implExp.deleteFolder = deleteFolder.wrapService(fs.deleteFolder);
154
156
  implExp.deleteLink = deleteLink.wrapService(fs.deleteLink);
@@ -1443,6 +1445,27 @@ var copyFolder;
1443
1445
  copyFolder.makeCaller = makeCaller;
1444
1446
  })(copyFolder || (copyFolder = {}));
1445
1447
  Object.freeze(copyFolder);
1448
+ var copyXAttrs;
1449
+ (function (copyXAttrs) {
1450
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.CopyXAttrsRequestBody);
1451
+ function wrapService(fn) {
1452
+ return buf => {
1453
+ const { src, dst, filter } = requestType.unpack(buf);
1454
+ const promise = fn(src, dst, filter);
1455
+ return { promise };
1456
+ };
1457
+ }
1458
+ copyXAttrs.wrapService = wrapService;
1459
+ function makeCaller(caller, objPath) {
1460
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'copyXAttrs');
1461
+ return (src, dst, filter) => caller
1462
+ .startPromiseCall(ipcPath, requestType.pack({
1463
+ src, dst, filter: filter !== null && filter !== void 0 ? filter : []
1464
+ }));
1465
+ }
1466
+ copyXAttrs.makeCaller = makeCaller;
1467
+ })(copyXAttrs || (copyXAttrs = {}));
1468
+ Object.freeze(copyXAttrs);
1446
1469
  var saveFile;
1447
1470
  (function (saveFile) {
1448
1471
  const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.SaveFileRequestBody);
@@ -184,6 +184,7 @@ function wrapWritableFS(fsImpl) {
184
184
  move: fsImpl.move.bind(fsImpl),
185
185
  copyFile: fsImpl.copyFile.bind(fsImpl),
186
186
  copyFolder: fsImpl.copyFolder.bind(fsImpl),
187
+ copyXAttrs: fsImpl.copyXAttrs.bind(fsImpl),
187
188
  writableFile: fsImpl.writableFile.bind(fsImpl),
188
189
  writableSubRoot: fsImpl.writableSubRoot.bind(fsImpl),
189
190
  saveFile: fsImpl.saveFile.bind(fsImpl),
@@ -85,6 +85,7 @@ export declare class DeviceFS implements WritableFS, Linkable {
85
85
  watchTree(path: string, depth: number | undefined, observer: Observer<FolderEvent | FileEvent>): () => void;
86
86
  copyFile(src: string, dst: string, overwrite?: boolean): Promise<void>;
87
87
  copyFolder(src: string, dst: string, mergeAndOverwrite?: boolean): Promise<void>;
88
+ copyXAttrs(src: string, dst: string, filter?: string[]): Promise<void>;
88
89
  saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
89
90
  saveFolder(folder: FS, dst: string, mergeAndOverwrite?: boolean): Promise<void>;
90
91
  }
@@ -829,6 +829,9 @@ class DeviceFS {
829
829
  }
830
830
  }
831
831
  }
832
+ copyXAttrs(src, dst, filter) {
833
+ throw (0, file_1.makeNoAttrsExc)(src);
834
+ }
832
835
  async saveFile(file, dst, overwrite = false) {
833
836
  const src = await file.getByteSource();
834
837
  const flags = {
@@ -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);
@@ -344,13 +344,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
344
344
  exc = (0, file_1.makeFileException)('ioError', `${this.name}/${info.name}`, exc);
345
345
  }
346
346
  else if (exc.objNotFound) {
347
- if (fromCurrentNodes) {
348
- // XXX this.fixMissingChildAndThrow() was removing object that has been moved on other device
349
- // Should we label found inconsistency, sot that it can be fixed later? Should we have lost&found?
350
- deferred.reject((0, file_1.makeFileException)('notFound', info.name, exc));
351
- return;
352
- }
353
- else {
347
+ if (!fromCurrentNodes) {
354
348
  try {
355
349
  const node = await this.getNonLocal(info);
356
350
  if (node) {
@@ -610,6 +604,8 @@ class FolderNode extends node_in_fs_1.NodeInFS {
610
604
  this.callRemoveObjOn('local', f);
611
605
  }
612
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?
613
609
  await this.doTransition(async (state, version) => {
614
610
  const child = state.nodes[name];
615
611
  if (!child) {
@@ -1187,9 +1183,10 @@ function addToTransitionState(state, f, key) {
1187
1183
  function diffNodes(current, remote, synced) {
1188
1184
  const currentNodesById = orderByIds(current.nodes);
1189
1185
  const syncedNodesById = orderByIds(synced.nodes);
1190
- const removed = { inLocal: [], inRemote: [] };
1186
+ const removedInLocal = [];
1191
1187
  const renamed = [];
1192
- const added = { inLocal: [], inRemote: [] };
1188
+ const addedInLocal = [];
1189
+ const addedInRemote = [];
1193
1190
  const rekeyed = [];
1194
1191
  const nameOverlaps = [];
1195
1192
  for (const remoteNode of Object.values(remote.nodes)) {
@@ -1216,7 +1213,7 @@ function diffNodes(current, remote, synced) {
1216
1213
  const syncedNode = syncedNodesById.get(remoteNode.objId);
1217
1214
  (0, assert_1.assert)(!!syncedNode);
1218
1215
  const localChanged = !(0, node_in_fs_1.areBytesEqual)(localNode.key, syncedNode.key);
1219
- const remoteChanged = !(0, node_in_fs_1.areBytesEqual)(localNode.key, syncedNode.key);
1216
+ const remoteChanged = !(0, node_in_fs_1.areBytesEqual)(remoteNode.key, syncedNode.key);
1220
1217
  rekeyed.push({
1221
1218
  local: localNode.name,
1222
1219
  remote: remoteNode.name,
@@ -1228,10 +1225,10 @@ function diffNodes(current, remote, synced) {
1228
1225
  else {
1229
1226
  const syncedNode = syncedNodesById.get(remoteNode.objId);
1230
1227
  if (syncedNode) {
1231
- removed.inLocal.push(remoteNode.name);
1228
+ removedInLocal.push(remoteNode.name);
1232
1229
  }
1233
1230
  else {
1234
- added.inRemote.push(remoteNode.name);
1231
+ addedInRemote.push(remoteNode.name);
1235
1232
  }
1236
1233
  if (current.nodes[remoteNode.name]) {
1237
1234
  nameOverlaps.push(remoteNode.name);
@@ -1241,13 +1238,13 @@ function diffNodes(current, remote, synced) {
1241
1238
  for (const localNode of currentNodesById.values()) {
1242
1239
  const syncedNode = syncedNodesById.get(localNode.objId);
1243
1240
  if (!syncedNode) {
1244
- added.inLocal.push(localNode.name);
1241
+ addedInLocal.push(localNode.name);
1245
1242
  }
1246
1243
  }
1247
1244
  return {
1248
- removed: reduceEmptyIn(removed),
1245
+ removed: { inLocal: removedInLocal },
1249
1246
  renamed: ((renamed.length > 0) ? renamed : undefined),
1250
- added: reduceEmptyIn(added),
1247
+ added: { inLocal: addedInLocal, inRemote: addedInRemote },
1251
1248
  rekeyed: ((rekeyed.length > 0) ? rekeyed : undefined),
1252
1249
  nameOverlaps: ((nameOverlaps.length > 0) ? nameOverlaps : undefined),
1253
1250
  };
@@ -1290,22 +1287,4 @@ function identifyChanges(originalNodes, newNodes) {
1290
1287
  }
1291
1288
  return { addedNodes, removedNodes, renamedNodes };
1292
1289
  }
1293
- function reduceEmptyIn(c) {
1294
- if (c.inLocal.length > 0) {
1295
- if (c.inRemote.length > 0) {
1296
- return c;
1297
- }
1298
- else {
1299
- return { inLocal: c.inLocal };
1300
- }
1301
- }
1302
- else {
1303
- if (c.inRemote.length > 0) {
1304
- return { inRemote: c.inRemote };
1305
- }
1306
- else {
1307
- return;
1308
- }
1309
- }
1310
- }
1311
1290
  Object.freeze(exports);
@@ -95,6 +95,7 @@ export declare class XspFS implements WritableFS {
95
95
  readonlyFile(path: string): Promise<ReadonlyFile>;
96
96
  writableFile(path: string, flags?: web3n.files.VersionedFileWriteFlags): Promise<WritableFile>;
97
97
  copyFile(src: string, dst: string, overwrite?: boolean): Promise<void>;
98
+ copyXAttrs(src: string, dst: string, filter?: string[]): Promise<void>;
98
99
  saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
99
100
  listFolder(folder: string): Promise<ListingEntry[]>;
100
101
  readJSONFile<T>(path: string): Promise<T>;
@@ -448,9 +448,31 @@ class XspFS {
448
448
  const sink = await this.getByteSink(dst, flags);
449
449
  await (0, pipe_1.pipe)(srcBytes, sink);
450
450
  }
451
+ async copyXAttrs(src, dst, filter) {
452
+ const srcAttrs = await this.listXAttrs(src);
453
+ if (srcAttrs.length === 0) {
454
+ return;
455
+ }
456
+ if (filter && (filter.length > 0)) {
457
+ for (let i = 0; i <= srcAttrs.length; i += 1) {
458
+ const attr = srcAttrs[i];
459
+ if (!filter.includes(attr)) {
460
+ srcAttrs.splice(i, 1);
461
+ i -= 1;
462
+ }
463
+ }
464
+ if (srcAttrs.length === 0) {
465
+ return;
466
+ }
467
+ }
468
+ const attrsToCopy = {};
469
+ for (const attr of srcAttrs) {
470
+ attrsToCopy[attr] = await this.getXAttr(src, attr);
471
+ }
472
+ await this.updateXAttrs(dst, { set: attrsToCopy });
473
+ }
451
474
  async saveFile(file, dst, overwrite = false) {
452
- const src = (file.v ?
453
- (await file.v.getByteSource()).src : await file.getByteSource());
475
+ const src = (file.v ? (await file.v.getByteSource()).src : await file.getByteSource());
454
476
  const flags = {
455
477
  create: true,
456
478
  exclusive: !overwrite,
@@ -785,7 +807,8 @@ class S {
785
807
  try {
786
808
  const startedUpload = await node.startUpload(opts, true);
787
809
  if (startedUpload) {
788
- const { uploadTaskId, uploadVersion } = startedUpload;
810
+ const { uploadTaskId, uploadVersion, completion } = startedUpload;
811
+ completion.catch(noop);
789
812
  return { uploadTaskId, uploadVersion };
790
813
  }
791
814
  else {
@@ -950,4 +973,5 @@ class S {
950
973
  }
951
974
  Object.freeze(S.prototype);
952
975
  Object.freeze(S);
976
+ function noop() { }
953
977
  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)(this.name, {
724
+ throw (0, exceptions_1.makeFSSyncException)(fsItemName, {
725
725
  versionMismatch: true,
726
726
  message: `Unknown version in branch: ${versionInBranch}`
727
727
  });
@@ -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}`));