core-3nweb-client-lib 0.43.8 → 0.43.9

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 (34) hide show
  1. package/build/api-defs/files.d.ts +68 -4
  2. package/build/core/storage/synced/obj-files.d.ts +1 -0
  3. package/build/core/storage/synced/obj-files.js +16 -0
  4. package/build/core/storage/synced/obj-status.d.ts +1 -0
  5. package/build/core/storage/synced/obj-status.js +18 -0
  6. package/build/core/storage/synced/storage.d.ts +6 -2
  7. package/build/core/storage/synced/storage.js +12 -17
  8. package/build/core/storage/synced/upsyncer.d.ts +10 -1
  9. package/build/core/storage/synced/upsyncer.js +72 -9
  10. package/build/core-ipc/file.d.ts +23 -4
  11. package/build/core-ipc/file.js +56 -80
  12. package/build/core-ipc/fs.js +46 -132
  13. package/build/lib-client/fs-utils/files.js +2 -0
  14. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -0
  15. package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -1
  16. package/build/lib-client/xsp-fs/common.d.ts +13 -21
  17. package/build/lib-client/xsp-fs/common.js +4 -16
  18. package/build/lib-client/xsp-fs/file-node.js +9 -22
  19. package/build/lib-client/xsp-fs/file.d.ts +4 -0
  20. package/build/lib-client/xsp-fs/file.js +18 -1
  21. package/build/lib-client/xsp-fs/folder-node.d.ts +5 -1
  22. package/build/lib-client/xsp-fs/folder-node.js +15 -27
  23. package/build/lib-client/xsp-fs/fs.d.ts +4 -0
  24. package/build/lib-client/xsp-fs/fs.js +25 -1
  25. package/build/lib-client/xsp-fs/link-node.js +3 -19
  26. package/build/lib-client/xsp-fs/node-in-fs.d.ts +18 -5
  27. package/build/lib-client/xsp-fs/node-in-fs.js +70 -12
  28. package/build/lib-common/processes/labelled-exec-pools.js +1 -3
  29. package/build/protos/asmail.proto.js +1436 -1437
  30. package/build/protos/file.proto.js +1077 -387
  31. package/build/protos/fs.proto.js +1395 -1396
  32. package/package.json +4 -4
  33. package/protos/file.proto +24 -12
  34. package/protos/fs.proto +8 -21
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.vListVersions = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.vStat = exports.readBytes = exports.fileMsgType = void 0;
19
+ exports.vListVersions = exports.vsUpload = exports.vsStartUpload = exports.vGetByteSink = exports.updateXAttrs = exports.vGetByteSource = exports.vReadJSON = exports.vReadTxt = exports.vReadBytes = exports.vListXAttrs = exports.vGetXAttr = exports.vStat = exports.readBytes = exports.fileMsgType = void 0;
20
20
  exports.makeFileCaller = makeFileCaller;
21
21
  exports.exposeFileService = exposeFileService;
22
22
  exports.packStats = packStats;
@@ -27,8 +27,8 @@ exports.packXAttrValue = packXAttrValue;
27
27
  exports.unpackXAttrValue = unpackXAttrValue;
28
28
  exports.packJSON = packJSON;
29
29
  exports.unpackJSON = unpackJSON;
30
- exports.packFileEvent = packFileEvent;
31
- exports.unpackFileEvent = unpackFileEvent;
30
+ exports.packEvent = packEvent;
31
+ exports.unpackEvent = unpackEvent;
32
32
  exports.versionedReadFlagsFromMsg = versionedReadFlagsFromMsg;
33
33
  exports.versionedReadFlagsToMsg = versionedReadFlagsToMsg;
34
34
  exports.xattrToMsg = xattrToMsg;
@@ -40,6 +40,7 @@ exports.remoteAdoptionOptsFromMsg = remoteAdoptionOptsFromMsg;
40
40
  const protobuf_msg_1 = require("../ipc-via-protobuf/protobuf-msg");
41
41
  const protobuf_type_1 = require("../lib-client/protobuf-type");
42
42
  const file_proto_1 = require("../protos/file.proto");
43
+ const common_proto_1 = require("../protos/common.proto");
43
44
  const connector_1 = require("../ipc-via-protobuf/connector");
44
45
  const error_1 = require("../lib-common/exceptions/error");
45
46
  const bytes_1 = require("./bytes");
@@ -101,6 +102,7 @@ function makeFileCaller(caller, fileMsg) {
101
102
  adoptRemote: vsAdoptRemote.makeCaller(caller, vsPath),
102
103
  };
103
104
  if (file.writable) {
105
+ file.v.sync.startUpload = vsStartUpload.makeCaller(caller, vsPath);
104
106
  file.v.sync.upload = vsUpload.makeCaller(caller, vsPath);
105
107
  }
106
108
  }
@@ -155,6 +157,7 @@ function exposeFileService(file, expServices) {
155
157
  adoptRemote: vsAdoptRemote.wrapService(file.v.sync.adoptRemote),
156
158
  };
157
159
  if (file.writable) {
160
+ implExp.v.sync.startedUpload = vsStartUpload.wrapService(file.v.sync.startUpload);
158
161
  implExp.v.sync.upload = vsUpload.wrapService(file.v.sync.upload);
159
162
  }
160
163
  }
@@ -185,6 +188,8 @@ function statsToMsg(s) {
185
188
  mtime: (s.mtime ? (0, protobuf_msg_1.toVal)(s.mtime.valueOf()) : undefined),
186
189
  size: (0, protobuf_msg_1.toOptVal)(s.size),
187
190
  version: (0, protobuf_msg_1.toOptVal)(s.version),
191
+ bytesNeedDownload: (0, protobuf_msg_1.toOptVal)(s.bytesNeedDownload),
192
+ versionSyncBranch: (0, protobuf_msg_1.toOptVal)(s.versionSyncBranch),
188
193
  };
189
194
  }
190
195
  function unpackStats(buf) {
@@ -198,6 +203,8 @@ function msgToStats(m) {
198
203
  isLink: (0, protobuf_msg_1.valOfOpt)(m.isLink),
199
204
  size: (0, protobuf_msg_1.valOfOptInt)(m.size),
200
205
  version: (0, protobuf_msg_1.valOfOptInt)(m.version),
206
+ bytesNeedDownload: (0, protobuf_msg_1.valOfOptInt)(m.bytesNeedDownload),
207
+ versionSyncBranch: (0, protobuf_msg_1.valOfOpt)(m.versionSyncBranch),
201
208
  ctime: (m.ctime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.ctime)) : undefined),
202
209
  mtime: (m.mtime ? new Date((0, protobuf_msg_1.valOfOptInt)(m.mtime)) : undefined),
203
210
  };
@@ -468,82 +475,19 @@ var getByteSource;
468
475
  getByteSource.makeCaller = makeCaller;
469
476
  })(getByteSource || (getByteSource = {}));
470
477
  Object.freeze(getByteSource);
471
- const fileEventType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileEventMsg);
472
- function packFileEvent(e) {
473
- const { type, path } = e;
474
- switch (type) {
475
- case 'file-change':
476
- return fileEventType.pack({
477
- type, path,
478
- src: (0, protobuf_msg_1.toVal)(e.src),
479
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
480
- });
481
- case 'removed':
482
- return fileEventType.pack({
483
- type, path,
484
- src: (0, protobuf_msg_1.toVal)(e.src)
485
- });
486
- case 'remote-change':
487
- return fileEventType.pack({
488
- type, path, newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
489
- });
490
- case 'remote-removal':
491
- return fileEventType.pack({
492
- type, path
493
- });
494
- case 'remote-arch-ver-removal':
495
- return fileEventType.pack({
496
- type, path, removedArchVer: (0, protobuf_msg_1.toOptVal)(e.removedArchVer)
497
- });
498
- case 'remote-version-archival':
499
- return fileEventType.pack({
500
- type, path, archivedVersion: (0, protobuf_msg_1.toOptVal)(e.archivedVersion)
501
- });
502
- default:
503
- throw new Error(`Unknown event type ${type}`);
504
- }
478
+ const stringValueType = protobuf_type_1.ProtoType.for(common_proto_1.common.StringValue);
479
+ function packEvent(e) {
480
+ return stringValueType.pack((0, protobuf_msg_1.toVal)(JSON.stringify(e)));
505
481
  }
506
- function unpackFileEvent(buf) {
507
- const m = fileEventType.unpack(buf);
508
- const { type, path } = m;
509
- switch (type) {
510
- case 'file-change':
511
- return {
512
- type, path,
513
- src: (0, protobuf_msg_1.valOf)(m.src),
514
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion)
515
- };
516
- case 'removed':
517
- return {
518
- type, path,
519
- src: (0, protobuf_msg_1.valOf)(m.src)
520
- };
521
- case 'remote-removal':
522
- return {
523
- type, path
524
- };
525
- case 'remote-change':
526
- return {
527
- type, path, newVersion: (0, protobuf_msg_1.intValOf)(m.newVersion)
528
- };
529
- case 'remote-arch-ver-removal':
530
- return {
531
- type, path, removedArchVer: (0, protobuf_msg_1.intValOf)(m.removedArchVer)
532
- };
533
- case 'remote-version-archival':
534
- return {
535
- type, path, archivedVersion: (0, protobuf_msg_1.intValOf)(m.archivedVersion)
536
- };
537
- default:
538
- throw new Error(`Unknown event type ${type}`);
539
- }
482
+ function unpackEvent(buf) {
483
+ return JSON.parse(stringValueType.unpack(buf).value);
540
484
  }
541
485
  var watch;
542
486
  (function (watch) {
543
487
  function wrapService(fn) {
544
488
  return buf => {
545
489
  const s = new rxjs_1.Subject();
546
- const obs = s.asObservable().pipe((0, operators_1.map)(packFileEvent));
490
+ const obs = s.asObservable().pipe((0, operators_1.map)(packEvent));
547
491
  const onCancel = fn(s);
548
492
  return { obs, onCancel };
549
493
  };
@@ -555,7 +499,7 @@ var watch;
555
499
  const s = new rxjs_1.Subject();
556
500
  const unsub = caller.startObservableCall(path, undefined, s);
557
501
  s.asObservable()
558
- .pipe((0, operators_1.map)(unpackFileEvent))
502
+ .pipe((0, operators_1.map)(unpackEvent))
559
503
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
560
504
  return unsub;
561
505
  };
@@ -1212,15 +1156,47 @@ function optionsToUploadLocalFromMsg(opts) {
1212
1156
  uploadVersion: (0, protobuf_msg_1.valOfOptInt)(opts.uploadVersion)
1213
1157
  };
1214
1158
  }
1159
+ var vsStartUpload;
1160
+ (function (vsStartUpload) {
1161
+ vsStartUpload.requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadRequestBody);
1162
+ vsStartUpload.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncStartUploadReplyBody);
1163
+ function wrapService(fn) {
1164
+ return buf => {
1165
+ const { opts } = vsStartUpload.requestType.unpack(buf);
1166
+ const promise = fn(optionsToUploadLocalFromMsg(opts))
1167
+ .then(startedUpload => vsStartUpload.replyType.pack({ startedUpload }));
1168
+ return { promise };
1169
+ };
1170
+ }
1171
+ vsStartUpload.wrapService = wrapService;
1172
+ function makeCaller(caller, objPath) {
1173
+ const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'startUpload');
1174
+ return opts => caller
1175
+ .startPromiseCall(path, vsStartUpload.requestType.pack({
1176
+ opts: optionsToUploadLocalToMsg(opts)
1177
+ }))
1178
+ .then(buf => {
1179
+ const { startedUpload } = vsStartUpload.replyType.unpack(buf);
1180
+ if (startedUpload) {
1181
+ const { uploadTaskId, uploadVersion } = startedUpload;
1182
+ return {
1183
+ uploadVersion: (0, protobuf_msg_1.fixInt)(uploadVersion),
1184
+ uploadTaskId: (0, protobuf_msg_1.fixInt)(uploadTaskId)
1185
+ };
1186
+ }
1187
+ });
1188
+ }
1189
+ vsStartUpload.makeCaller = makeCaller;
1190
+ })(vsStartUpload || (exports.vsStartUpload = vsStartUpload = {}));
1191
+ Object.freeze(vsStartUpload);
1215
1192
  var vsUpload;
1216
1193
  (function (vsUpload) {
1217
- const requestType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadRequestBody);
1218
- const replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadReplyBody);
1194
+ vsUpload.replyType = protobuf_type_1.ProtoType.for(file_proto_1.file.FileSyncUploadReplyBody);
1219
1195
  function wrapService(fn) {
1220
1196
  return buf => {
1221
- const { opts } = requestType.unpack(buf);
1197
+ const { opts } = vsStartUpload.requestType.unpack(buf);
1222
1198
  const promise = fn(optionsToUploadLocalFromMsg(opts))
1223
- .then(uploadedVersion => replyType.pack({
1199
+ .then(uploadedVersion => vsUpload.replyType.pack({
1224
1200
  uploadedVersion: (0, protobuf_msg_1.toOptVal)(uploadedVersion)
1225
1201
  }));
1226
1202
  return { promise };
@@ -1230,13 +1206,13 @@ var vsUpload;
1230
1206
  function makeCaller(caller, objPath) {
1231
1207
  const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'upload');
1232
1208
  return opts => caller
1233
- .startPromiseCall(path, requestType.pack({
1209
+ .startPromiseCall(path, vsStartUpload.requestType.pack({
1234
1210
  opts: optionsToUploadLocalToMsg(opts)
1235
1211
  }))
1236
- .then(buf => (0, protobuf_msg_1.valOfOptInt)(replyType.unpack(buf).uploadedVersion));
1212
+ .then(buf => (0, protobuf_msg_1.valOfOptInt)(vsUpload.replyType.unpack(buf).uploadedVersion));
1237
1213
  }
1238
1214
  vsUpload.makeCaller = makeCaller;
1239
- })(vsUpload || (vsUpload = {}));
1215
+ })(vsUpload || (exports.vsUpload = vsUpload = {}));
1240
1216
  Object.freeze(vsUpload);
1241
1217
  function remoteAdoptionOptsToMsg(opts) {
1242
1218
  if (!opts) {
@@ -110,6 +110,7 @@ function makeFSCaller(caller, fsMsg) {
110
110
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.makeCaller(caller, vsPath)
111
111
  };
112
112
  if (fs.writable) {
113
+ fs.v.sync.startUpload = vsStartUpload.makeCaller(caller, vsPath);
113
114
  fs.v.sync.upload = vsUpload.makeCaller(caller, vsPath);
114
115
  fs.v.sync.adoptRemoteFolderItem = vsAdoptRemoteFolderItem.makeCaller(caller, vsPath);
115
116
  }
@@ -136,8 +137,8 @@ function exposeFSService(fs, expServices) {
136
137
  readonlySubRoot: readonlySubRoot.wrapService(fs.readonlySubRoot, expServices),
137
138
  select: select.wrapService(fs.select, expServices),
138
139
  stat: stat.wrapService(fs.stat),
139
- watchFolder: watch.wrapService(fs.watchFolder, packFSEvent),
140
- watchFile: watch.wrapService(fs.watchFile, file_1.packFileEvent),
140
+ watchFolder: watch.wrapService(fs.watchFolder),
141
+ watchFile: watch.wrapService(fs.watchFile),
141
142
  watchTree: watchTree.wrapService(fs.watchTree),
142
143
  };
143
144
  if (fs.writable) {
@@ -188,6 +189,7 @@ function exposeFSService(fs, expServices) {
188
189
  diffCurrentAndRemoteFolderVersions: vsDiffCurrentAndRemoteFolderVersions.wrapService(fs.v.sync.diffCurrentAndRemoteFolderVersions)
189
190
  };
190
191
  if (fs.writable) {
192
+ implExp.v.sync.startUpload = vsStartUpload.wrapService(fs.v.sync.startUpload);
191
193
  implExp.v.sync.upload = vsUpload.wrapService(fs.v.sync.upload);
192
194
  implExp.v.sync.adoptRemoteFolderItem = vsAdoptRemoteFolderItem.wrapService(fs.v.sync.adoptRemoteFolderItem);
193
195
  }
@@ -382,127 +384,6 @@ var readLink;
382
384
  readLink.makeCaller = makeCaller;
383
385
  })(readLink || (readLink = {}));
384
386
  Object.freeze(readLink);
385
- const fsEventMsgType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSEventMsg);
386
- function packFSEvent(e) {
387
- const { type, path } = e;
388
- switch (type) {
389
- case 'removed':
390
- return fsEventMsgType.pack({
391
- type, path,
392
- src: (0, protobuf_msg_1.toVal)(e.src)
393
- });
394
- case 'remote-removal':
395
- return fsEventMsgType.pack({
396
- type, path
397
- });
398
- case 'file-change':
399
- return fsEventMsgType.pack({
400
- type, path,
401
- src: (0, protobuf_msg_1.toVal)(e.src),
402
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
403
- });
404
- case 'remote-change':
405
- return fsEventMsgType.pack({
406
- type, path,
407
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion)
408
- });
409
- case 'entry-addition':
410
- return fsEventMsgType.pack({
411
- type, path,
412
- src: (0, protobuf_msg_1.toVal)(e.src),
413
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
414
- entry: lsEntryToMsg(e.entry),
415
- moveLabel: (0, protobuf_msg_1.toOptVal)(e.moveLabel)
416
- });
417
- case 'entry-removal':
418
- return fsEventMsgType.pack({
419
- type, path,
420
- src: (0, protobuf_msg_1.toVal)(e.src),
421
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
422
- name: (0, protobuf_msg_1.toVal)(e.name),
423
- moveLabel: (0, protobuf_msg_1.toOptVal)(e.moveLabel)
424
- });
425
- case 'entry-renaming':
426
- return fsEventMsgType.pack({
427
- type, path,
428
- src: (0, protobuf_msg_1.toVal)(e.src),
429
- newVersion: (0, protobuf_msg_1.toOptVal)(e.newVersion),
430
- oldName: (0, protobuf_msg_1.toVal)(e.oldName),
431
- newName: (0, protobuf_msg_1.toVal)(e.newName)
432
- });
433
- case 'remote-arch-ver-removal':
434
- return fsEventMsgType.pack({
435
- type, path,
436
- removedArchVer: (0, protobuf_msg_1.toVal)(e.removedArchVer)
437
- });
438
- case 'remote-version-archival':
439
- return fsEventMsgType.pack({
440
- type, path,
441
- archivedVersion: (0, protobuf_msg_1.toVal)(e.archivedVersion)
442
- });
443
- default:
444
- throw new Error(`Unknown event type ${type}`);
445
- }
446
- }
447
- function unpackFSEvent(buf) {
448
- const m = fsEventMsgType.unpack(buf);
449
- const { type, path } = m;
450
- switch (type) {
451
- case 'entry-addition':
452
- return {
453
- type, path,
454
- src: (0, protobuf_msg_1.valOf)(m.src),
455
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
456
- entry: lsEntryFromMsg(m.entry),
457
- moveLabel: (0, protobuf_msg_1.valOfOptInt)(m.moveLabel)
458
- };
459
- case 'entry-removal':
460
- return {
461
- type, path,
462
- src: (0, protobuf_msg_1.valOf)(m.src),
463
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
464
- name: (0, protobuf_msg_1.valOf)(m.name),
465
- moveLabel: (0, protobuf_msg_1.valOfOptInt)(m.moveLabel)
466
- };
467
- case 'entry-renaming':
468
- return {
469
- type, path,
470
- src: (0, protobuf_msg_1.valOf)(m.src),
471
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion),
472
- oldName: (0, protobuf_msg_1.valOf)(m.oldName),
473
- newName: (0, protobuf_msg_1.valOf)(m.newName)
474
- };
475
- case 'file-change':
476
- return {
477
- type, path,
478
- src: (0, protobuf_msg_1.valOf)(m.src),
479
- newVersion: (0, protobuf_msg_1.valOfOptInt)(m.newVersion)
480
- };
481
- case 'removed':
482
- return {
483
- type, path,
484
- src: (0, protobuf_msg_1.valOf)(m.src)
485
- };
486
- case 'remote-removal':
487
- return {
488
- type, path
489
- };
490
- case 'remote-change':
491
- return {
492
- type, path, newVersion: (0, protobuf_msg_1.intValOf)(m.newVersion)
493
- };
494
- case 'remote-arch-ver-removal':
495
- return {
496
- type, path, removedArchVer: (0, protobuf_msg_1.intValOf)(m.removedArchVer)
497
- };
498
- case 'remote-version-archival':
499
- return {
500
- type, path, archivedVersion: (0, protobuf_msg_1.intValOf)(m.archivedVersion)
501
- };
502
- default:
503
- throw new Error(`Unknown event type ${type}`);
504
- }
505
- }
506
387
  function lsEntryToMsg(e) {
507
388
  return {
508
389
  name: e.name,
@@ -530,34 +411,34 @@ function lsEntryFromMsg(m) {
530
411
  }
531
412
  var watch;
532
413
  (function (watch) {
533
- function wrapService(fn, packEvent) {
414
+ function wrapService(fn) {
534
415
  return buf => {
535
416
  const { path } = reqWithPathType.unpack(buf);
536
417
  const s = new rxjs_1.Subject();
537
- const obs = s.asObservable().pipe((0, operators_1.map)(packEvent));
418
+ const obs = s.asObservable().pipe((0, operators_1.map)(file_1.packEvent));
538
419
  const onCancel = fn(path, s);
539
420
  return { obs, onCancel };
540
421
  };
541
422
  }
542
423
  watch.wrapService = wrapService;
543
- function makeCaller(caller, ipcPath, unpackEvent) {
424
+ function makeCaller(caller, ipcPath) {
544
425
  return (path, obs) => {
545
426
  const s = new rxjs_1.Subject();
546
427
  const unsub = caller.startObservableCall(ipcPath, reqWithPathType.pack({ path }), s);
547
428
  s.asObservable()
548
- .pipe((0, operators_1.map)(unpackEvent))
429
+ .pipe((0, operators_1.map)(file_1.unpackEvent))
549
430
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
550
431
  return unsub;
551
432
  };
552
433
  }
553
434
  function makeFolderCaller(caller, objPath) {
554
435
  const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'watchFolder');
555
- return makeCaller(caller, ipcPath, unpackFSEvent);
436
+ return makeCaller(caller, ipcPath);
556
437
  }
557
438
  watch.makeFolderCaller = makeFolderCaller;
558
439
  function makeFileCaller(caller, objPath) {
559
440
  const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'watchFile');
560
- return makeCaller(caller, ipcPath, file_1.unpackFileEvent);
441
+ return makeCaller(caller, ipcPath);
561
442
  }
562
443
  watch.makeFileCaller = makeFileCaller;
563
444
  })(watch || (watch = {}));
@@ -569,7 +450,7 @@ var watchTree;
569
450
  return buf => {
570
451
  const { path, depth } = requestType.unpack(buf);
571
452
  const s = new rxjs_1.Subject();
572
- const obs = s.asObservable().pipe((0, operators_1.map)(packFSEvent));
453
+ const obs = s.asObservable().pipe((0, operators_1.map)(file_1.packEvent));
573
454
  const onCancel = fn(path, (0, protobuf_msg_1.valOfOpt)(depth), s);
574
455
  return { obs, onCancel };
575
456
  };
@@ -581,7 +462,7 @@ var watchTree;
581
462
  const s = new rxjs_1.Subject();
582
463
  const unsub = caller.startObservableCall(ipcPath, requestType.pack({ path, depth: (0, protobuf_msg_1.toOptVal)(depth) }), s);
583
464
  s.asObservable()
584
- .pipe((0, operators_1.map)(unpackFSEvent))
465
+ .pipe((0, operators_1.map)(file_1.unpackEvent))
585
466
  .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
586
467
  return unsub;
587
468
  };
@@ -1967,10 +1848,43 @@ var vsDownload;
1967
1848
  vsDownload.makeCaller = makeCaller;
1968
1849
  })(vsDownload || (vsDownload = {}));
1969
1850
  Object.freeze(vsDownload);
1851
+ var vsStartUpload;
1852
+ (function (vsStartUpload) {
1853
+ const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadRequestBody);
1854
+ const replyType = file.vsStartUpload.replyType;
1855
+ function wrapService(fn) {
1856
+ return buf => {
1857
+ const { path, opts } = requestType.unpack(buf);
1858
+ const promise = fn(path, file.optionsToUploadLocalFromMsg(opts))
1859
+ .then(startedUpload => replyType.pack({ startedUpload }));
1860
+ return { promise };
1861
+ };
1862
+ }
1863
+ vsStartUpload.wrapService = wrapService;
1864
+ function makeCaller(caller, objPath) {
1865
+ const ipcPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'startUpload');
1866
+ return (path, opts) => caller
1867
+ .startPromiseCall(ipcPath, requestType.pack({
1868
+ path, opts: file.optionsToUploadLocalToMsg(opts)
1869
+ }))
1870
+ .then(buf => {
1871
+ const { startedUpload } = replyType.unpack(buf);
1872
+ if (startedUpload) {
1873
+ const { uploadTaskId, uploadVersion } = startedUpload;
1874
+ return {
1875
+ uploadVersion: (0, protobuf_msg_1.fixInt)(uploadVersion),
1876
+ uploadTaskId: (0, protobuf_msg_1.fixInt)(uploadTaskId)
1877
+ };
1878
+ }
1879
+ });
1880
+ }
1881
+ vsStartUpload.makeCaller = makeCaller;
1882
+ })(vsStartUpload || (vsStartUpload = {}));
1883
+ Object.freeze(vsStartUpload);
1970
1884
  var vsUpload;
1971
1885
  (function (vsUpload) {
1972
1886
  const requestType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadRequestBody);
1973
- const replyType = protobuf_type_1.ProtoType.for(fs_proto_1.fs.FSSyncUploadReplyBody);
1887
+ const replyType = file.vsUpload.replyType;
1974
1888
  function wrapService(fn) {
1975
1889
  return buf => {
1976
1890
  const { path, opts } = requestType.unpack(buf);
@@ -89,6 +89,7 @@ function wrapWritableFileSyncAPI(sImpl) {
89
89
  status: sImpl.status.bind(sImpl),
90
90
  download: sImpl.download.bind(sImpl),
91
91
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
92
+ startUpload: sImpl.startUpload.bind(sImpl),
92
93
  upload: sImpl.upload.bind(sImpl),
93
94
  adoptRemote: sImpl.adoptRemote.bind(sImpl),
94
95
  };
@@ -237,6 +238,7 @@ function wrapWritableFSSyncAPI(sImpl) {
237
238
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
238
239
  adoptRemote: sImpl.adoptRemote.bind(sImpl),
239
240
  diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
241
+ startUpload: sImpl.startUpload.bind(sImpl),
240
242
  upload: sImpl.upload.bind(sImpl),
241
243
  adoptRemoteFolderItem: sImpl.adoptRemoteFolderItem.bind(sImpl),
242
244
  };
@@ -40,6 +40,7 @@ export declare class ObjOnDisk {
40
40
  };
41
41
  private segsThatNeedDownload;
42
42
  doesFileNeedDownload(): boolean;
43
+ numOfBytesNeedingDownload(): number;
43
44
  downloadMissingSections(): Promise<void>;
44
45
  }
45
46
  export interface ObjDownloader {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2018 - 2020, 2022 3NSoft Inc.
3
+ Copyright (C) 2018 - 2020, 2022, 2025 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
@@ -200,6 +200,13 @@ class ObjOnDisk {
200
200
  doesFileNeedDownload() {
201
201
  return (this.segsThatNeedDownload().length === 0);
202
202
  }
203
+ numOfBytesNeedingDownload() {
204
+ let totalLen = 0;
205
+ for (const { len } of this.segsThatNeedDownload()) {
206
+ totalLen += len;
207
+ }
208
+ return totalLen;
209
+ }
203
210
  async downloadMissingSections() {
204
211
  const needDownload = this.segsThatNeedDownload();
205
212
  for (const chunk of needDownload) {
@@ -1,9 +1,9 @@
1
- import { ScryptGenParams } from '../key-derivation';
2
- import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
3
- import { Observable } from 'rxjs';
4
- import { LogError } from '../logging/log-to-file';
5
- export { AsyncSBoxCryptor } from 'xsp-files';
6
- export { FolderInJSON } from './folder-node';
1
+ import type { ScryptGenParams } from '../key-derivation';
2
+ import type { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
3
+ import type { Observable } from 'rxjs';
4
+ import type { LogError } from '../logging/log-to-file';
5
+ export type { AsyncSBoxCryptor } from 'xsp-files';
6
+ export type { FolderInJSON } from './folder-node';
7
7
  type StorageType = web3n.files.FSType;
8
8
  type FolderEvent = web3n.files.FolderEvent;
9
9
  type FileEvent = web3n.files.FileEvent;
@@ -12,6 +12,7 @@ type SyncStatus = web3n.files.SyncStatus;
12
12
  type OptionsToAdopteRemote = web3n.files.OptionsToAdopteRemote;
13
13
  type FSSyncException = web3n.files.FSSyncException;
14
14
  type FileException = web3n.files.FileException;
15
+ type UploadEvent = web3n.files.UploadEvent;
15
16
  export type FSChangeSrc = web3n.files.FSChangeEvent['src'];
16
17
  export interface Node {
17
18
  objId: string;
@@ -20,18 +21,6 @@ export interface Node {
20
21
  }
21
22
  export type NodeType = 'file' | 'link' | 'folder';
22
23
  export type ObjId = string | null;
23
- /**
24
- * This is a container for file system nodes.
25
- *
26
- * Current implementation performs two functions: container for nodes, and a
27
- * provider of node type, corresponding to given object.
28
- * The later function, used by synced storage for conflict resolution, takes
29
- * advantage of container not forgeting nodes, like cache may do.
30
- * So, at least for local storage's sake, this container may be refactored to
31
- * act more like cache, and even then we shouldn't forget about cascading keys
32
- * and a need to keep parent nodes in memory, while child nodes are in
33
- * use/cache.
34
- */
35
24
  export declare class NodesContainer {
36
25
  private nodes;
37
26
  private promises;
@@ -51,7 +40,7 @@ export interface NodeEvent {
51
40
  objId: ObjId;
52
41
  parentObjId?: ObjId;
53
42
  childObjId?: ObjId;
54
- event: FolderEvent | FileEvent | RemoteEvent;
43
+ event: FolderEvent | FileEvent | RemoteEvent | UploadEvent;
55
44
  }
56
45
  export interface Storage {
57
46
  readonly type: StorageType;
@@ -113,13 +102,16 @@ export interface SyncedStorage extends Storage {
113
102
  getRootKeyDerivParamsFromServer(): Promise<ScryptGenParams>;
114
103
  adoptRemote(objId: ObjId, opts: OptionsToAdopteRemote | undefined): Promise<number | undefined>;
115
104
  updateStatusInfo(objId: ObjId): Promise<SyncStatus>;
116
- isObjOnDisk(objId: ObjId): Promise<boolean>;
117
105
  isRemoteVersionOnDisk(objId: ObjId, version: number): Promise<'partial' | 'complete' | 'none'>;
118
106
  download(objId: ObjId, version: number): Promise<void>;
119
- upload(objId: ObjId, localVersion: number, uploadVersion: number, uploadHeader: UploadHeaderChange | undefined, createOnRemote: boolean): Promise<void>;
107
+ startUpload(objId: ObjId, localVersion: number, uploadVersion: number, uploadHeader: UploadHeaderChange | undefined, createOnRemote: boolean, eventSink: (event: UploadEvent) => void): Promise<{
108
+ uploadTaskId: number;
109
+ completion: Promise<void>;
110
+ }>;
120
111
  dropCachedLocalObjVersionsLessOrEqual(objId: ObjId, localVersion: number): void;
121
112
  uploadObjRemoval(objId: ObjId): Promise<void>;
122
113
  status(objId: ObjId): Promise<SyncedObjStatus>;
114
+ getNumOfBytesNeedingDownload(objId: ObjId, version: number): Promise<number | 'unknown'>;
123
115
  suspendNetworkActivity(): void;
124
116
  resumeNetworkActivity(): void;
125
117
  }
@@ -21,18 +21,6 @@ exports.wrapStorageImplementation = wrapStorageImplementation;
21
21
  exports.wrapSyncStorageImplementation = wrapSyncStorageImplementation;
22
22
  exports.isSyncedStorage = isSyncedStorage;
23
23
  exports.setPathInExc = setPathInExc;
24
- /**
25
- * This is a container for file system nodes.
26
- *
27
- * Current implementation performs two functions: container for nodes, and a
28
- * provider of node type, corresponding to given object.
29
- * The later function, used by synced storage for conflict resolution, takes
30
- * advantage of container not forgeting nodes, like cache may do.
31
- * So, at least for local storage's sake, this container may be refactored to
32
- * act more like cache, and even then we shouldn't forget about cascading keys
33
- * and a need to keep parent nodes in memory, while child nodes are in
34
- * use/cache.
35
- */
36
24
  class NodesContainer {
37
25
  constructor() {
38
26
  this.nodes = new Map();
@@ -125,23 +113,23 @@ function wrapSyncStorageImplementation(impl) {
125
113
  for (const [field, value] of Object.entries(storageWrap)) {
126
114
  wrap[field] = value;
127
115
  }
128
- wrap.getRootKeyDerivParamsFromServer =
129
- impl.getRootKeyDerivParamsFromServer.bind(impl);
116
+ wrap.getRootKeyDerivParamsFromServer = impl.getRootKeyDerivParamsFromServer.bind(impl);
130
117
  wrap.getObjSrcOfRemoteVersion = impl.getObjSrcOfRemoteVersion.bind(impl);
131
118
  wrap.archiveVersionOnServer = impl.archiveVersionOnServer.bind(impl);
132
119
  wrap.isRemoteVersionOnDisk = impl.isRemoteVersionOnDisk.bind(impl);
133
120
  wrap.download = impl.download.bind(impl);
134
- wrap.upload = impl.upload.bind(impl);
121
+ wrap.startUpload = impl.startUpload.bind(impl);
135
122
  wrap.uploadObjRemoval = impl.uploadObjRemoval.bind(impl);
136
123
  wrap.dropCachedLocalObjVersionsLessOrEqual = impl.dropCachedLocalObjVersionsLessOrEqual.bind(impl);
137
124
  wrap.adoptRemote = impl.adoptRemote.bind(impl);
138
125
  wrap.updateStatusInfo = impl.updateStatusInfo.bind(impl);
139
126
  wrap.suspendNetworkActivity = impl.suspendNetworkActivity.bind(impl);
140
127
  wrap.resumeNetworkActivity = impl.resumeNetworkActivity.bind(impl);
128
+ wrap.getNumOfBytesNeedingDownload = impl.getNumOfBytesNeedingDownload.bind(impl);
141
129
  return Object.freeze(wrap);
142
130
  }
143
131
  function isSyncedStorage(storage) {
144
- return !!storage.upload;
132
+ return !!storage.startUpload;
145
133
  }
146
134
  function setPathInExc(exc, path) {
147
135
  if ((exc.type === 'fs-sync') || (exc.type === 'file')) {