core-3nweb-client-lib 0.44.2 → 0.44.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 (33) hide show
  1. package/build/api-defs/files.d.ts +20 -5
  2. package/build/core/id-manager/key-storage.d.ts +1 -0
  3. package/build/core/id-manager/key-storage.js +18 -3
  4. package/build/core/storage/synced/remote-events.d.ts +3 -0
  5. package/build/core/storage/synced/remote-events.js +24 -1
  6. package/build/core/storage/synced/storage.d.ts +1 -0
  7. package/build/core/storage/synced/storage.js +5 -2
  8. package/build/core-ipc/file.d.ts +4 -0
  9. package/build/core-ipc/file.js +22 -1
  10. package/build/core-ipc/fs.js +13 -11
  11. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  12. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  13. package/build/lib-client/fs-utils/files.js +5 -1
  14. package/build/lib-client/xsp-fs/common.d.ts +1 -0
  15. package/build/lib-client/xsp-fs/common.js +1 -0
  16. package/build/lib-client/xsp-fs/file-node.d.ts +2 -1
  17. package/build/lib-client/xsp-fs/file-node.js +8 -4
  18. package/build/lib-client/xsp-fs/file.d.ts +1 -0
  19. package/build/lib-client/xsp-fs/file.js +3 -0
  20. package/build/lib-client/xsp-fs/folder-node.d.ts +3 -2
  21. package/build/lib-client/xsp-fs/folder-node.js +48 -61
  22. package/build/lib-client/xsp-fs/fs.d.ts +3 -2
  23. package/build/lib-client/xsp-fs/fs.js +5 -2
  24. package/build/lib-client/xsp-fs/link-node.d.ts +1 -0
  25. package/build/lib-client/xsp-fs/link-node.js +3 -0
  26. package/build/lib-client/xsp-fs/node-in-fs.d.ts +1 -1
  27. package/build/lib-client/xsp-fs/node-in-fs.js +14 -12
  28. package/build/lib-common/exceptions/error.js +2 -1
  29. package/build/protos/asmail.proto.js +158 -158
  30. package/build/protos/fs.proto.js +158 -158
  31. package/package.json +1 -1
  32. package/protos/file.proto +4 -0
  33. package/protos/fs.proto +7 -4
@@ -86,6 +86,7 @@ function wrapWritableFileSyncAPI(sImpl) {
86
86
  return;
87
87
  }
88
88
  const w = {
89
+ whenConnected: sImpl.whenConnected.bind(sImpl),
89
90
  status: sImpl.status.bind(sImpl),
90
91
  startDownload: sImpl.startDownload.bind(sImpl),
91
92
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
@@ -140,6 +141,7 @@ function wrapReadonlyFileSyncAPI(sImpl) {
140
141
  return;
141
142
  }
142
143
  const w = {
144
+ whenConnected: sImpl.whenConnected.bind(sImpl),
143
145
  status: sImpl.status.bind(sImpl),
144
146
  startDownload: sImpl.startDownload.bind(sImpl),
145
147
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
@@ -235,6 +237,7 @@ function wrapWritableFSSyncAPI(sImpl) {
235
237
  return;
236
238
  }
237
239
  const w = {
240
+ whenConnected: sImpl.whenConnected.bind(sImpl),
238
241
  status: sImpl.status.bind(sImpl),
239
242
  startDownload: sImpl.startDownload.bind(sImpl),
240
243
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
@@ -248,7 +251,7 @@ function wrapWritableFSSyncAPI(sImpl) {
248
251
  getRemoteFileItem: sImpl.getRemoteFileItem.bind(sImpl),
249
252
  getRemoteFolderItem: sImpl.getRemoteFolderItem.bind(sImpl),
250
253
  diffCurrentAndRemoteFileVersions: sImpl.diffCurrentAndRemoteFileVersions.bind(sImpl),
251
- mergeFolderCurrentAndRemoteVersions: sImpl.mergeFolderCurrentAndRemoteVersions.bind(sImpl),
254
+ absorbRemoteFolderChanges: sImpl.absorbRemoteFolderChanges.bind(sImpl),
252
255
  };
253
256
  return Object.freeze(w);
254
257
  }
@@ -303,6 +306,7 @@ function wrapReadonlyFSSyncAPI(sImpl) {
303
306
  return;
304
307
  }
305
308
  const w = {
309
+ whenConnected: sImpl.whenConnected.bind(sImpl),
306
310
  status: sImpl.status.bind(sImpl),
307
311
  startDownload: sImpl.startDownload.bind(sImpl),
308
312
  isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
@@ -121,6 +121,7 @@ export interface SyncedStorage extends Storage {
121
121
  suspendNetworkActivity(): void;
122
122
  resumeNetworkActivity(): void;
123
123
  connectionEvent$: Observable<StorageConnectionStatus>;
124
+ whenConnected(): Promise<void>;
124
125
  }
125
126
  export interface SyncedObjStatus extends LocalObjStatus {
126
127
  syncStatus(): SyncStatus;
@@ -127,6 +127,7 @@ function wrapSyncStorageImplementation(impl) {
127
127
  wrap.resumeNetworkActivity = impl.resumeNetworkActivity.bind(impl);
128
128
  wrap.getNumOfBytesNeedingDownload = impl.getNumOfBytesNeedingDownload.bind(impl);
129
129
  wrap.connectionEvent$ = impl.connectionEvent$;
130
+ wrap.whenConnected = impl.whenConnected.bind(impl);
130
131
  return Object.freeze(wrap);
131
132
  }
132
133
  function isSyncedStorage(storage) {
@@ -41,9 +41,10 @@ export declare class FileNode extends NodeInFS<FilePersistance> {
41
41
  static makeForNew(storage: Storage, parentId: string, name: string, key: Uint8Array): Promise<FileNode>;
42
42
  static makeForExisting(storage: Storage, parentId: string, fileName: string, objId: string, key: Uint8Array): Promise<FileNode>;
43
43
  static makeFromLinkParams(storage: Storage, params: FileLinkParams): Promise<FileNode>;
44
- private static initWithAttrs;
44
+ static readNodeFromObjBytes(storage: Storage, parentId: string | undefined, fileName: string, objId: string, src: ObjSource, key: Uint8Array): Promise<FileNode>;
45
45
  protected setCurrentStateFrom(src: ObjSource): Promise<void>;
46
46
  private setUpdatedState;
47
+ getStorage(): Storage;
47
48
  getStats(flags?: VersionedReadFlags): Promise<Stats>;
48
49
  readSrc(flags: VersionedReadFlags | undefined): Promise<{
49
50
  src: FileByteSource;
@@ -103,17 +103,18 @@ class FileNode extends node_in_fs_1.NodeInFS {
103
103
  if (!parentId) {
104
104
  throw new Error("Bad parent id");
105
105
  }
106
- const file = await FileNode.initWithAttrs(storage, parentId, fileName, objId, key);
106
+ const src = await storage.getObjSrc(objId);
107
+ const file = await FileNode.readNodeFromObjBytes(storage, parentId, fileName, objId, src, key);
107
108
  return file;
108
109
  }
109
110
  static async makeFromLinkParams(storage, params) {
110
111
  const { objId, fileName } = params;
111
112
  const key = buffer_utils_1.base64.open(params.fKey);
112
- const file = await FileNode.initWithAttrs(storage, undefined, fileName, objId, key);
113
+ const src = await storage.getObjSrc(objId);
114
+ const file = await FileNode.readNodeFromObjBytes(storage, undefined, fileName, objId, src, key);
113
115
  return file;
114
116
  }
115
- static async initWithAttrs(storage, parentId, fileName, objId, key) {
116
- const src = await storage.getObjSrc(objId);
117
+ static async readNodeFromObjBytes(storage, parentId, fileName, objId, src, key) {
117
118
  const file = new FileNode(storage, fileName, objId, src.version, parentId, key);
118
119
  await file.setCurrentStateFrom(src);
119
120
  return file;
@@ -126,6 +127,9 @@ class FileNode extends node_in_fs_1.NodeInFS {
126
127
  this.fileSize = fileAttrs.size;
127
128
  super.setUpdatedParams(version, fileAttrs.attrs, fileAttrs.xattrs);
128
129
  }
130
+ getStorage() {
131
+ return this.storage;
132
+ }
129
133
  async getStats(flags) {
130
134
  const { stats, attrs } = await this.getStatsAndSize(flags);
131
135
  stats.size = (attrs ? attrs.size : this.fileSize);
@@ -100,6 +100,7 @@ declare class V implements WritableFileVersionedAPI, N {
100
100
  declare class S implements WritableFileSyncAPI {
101
101
  private readonly n;
102
102
  constructor(n: N);
103
+ whenConnected(): Promise<void>;
103
104
  startUpload(opts?: OptionsToUploadLocal): Promise<{
104
105
  uploadVersion: number;
105
106
  uploadTaskId: number;
@@ -224,6 +224,9 @@ class S {
224
224
  this.n = n;
225
225
  Object.freeze(this);
226
226
  }
227
+ async whenConnected() {
228
+ return (await this.n.getNode()).getStorage().whenConnected();
229
+ }
227
230
  async startUpload(opts) {
228
231
  this.n.ensureIsWritable();
229
232
  const node = await this.n.getNode();
@@ -14,7 +14,7 @@ type OptionsToAdoptRemoteItem = web3n.files.OptionsToAdoptRemoteItem;
14
14
  type OptionsToUploadLocal = web3n.files.OptionsToUploadLocal;
15
15
  type VersionedReadFlags = web3n.files.VersionedReadFlags;
16
16
  type Stats = web3n.files.Stats;
17
- type OptionsToMergeFolderVersions = web3n.files.OptionsToMergeFolderVersions;
17
+ type OptionsToAdoptRemoteFolderChanges = web3n.files.OptionsToAdoptRemoteFolderChanges;
18
18
  export interface NodeInfo {
19
19
  /**
20
20
  * This is a usual file name.
@@ -96,6 +96,7 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
96
96
  hasChild(childName: string, throwIfMissing?: boolean): boolean;
97
97
  getNode<T extends NodeInFS<any>>(type: NodeType | undefined, name: string, undefOnMissing?: boolean): Promise<T | undefined>;
98
98
  private getOrMakeChildNodeForInfo;
99
+ private getNonLocal;
99
100
  getFolder(name: string, undefOnMissing?: boolean): Promise<FolderNode | undefined>;
100
101
  getFile(name: string, undefOnMissing?: boolean): Promise<FileNode | undefined>;
101
102
  getLink(name: string, undefOnMissing?: boolean): Promise<LinkNode | undefined>;
@@ -178,6 +179,6 @@ export declare class FolderNode extends NodeInFS<FolderPersistance> {
178
179
  diffCurrentAndRemote(remoteVersion: number | undefined): Promise<FolderDiff | undefined>;
179
180
  getRemoteItemNode<T extends NodeInFS<any>>(remoteItemName: string, remoteVersion: number | undefined): Promise<T>;
180
181
  getStorage(): Storage;
181
- mergeCurrentAndRemoteVersions(opts: OptionsToMergeFolderVersions | undefined): Promise<number | undefined>;
182
+ absorbRemoteChanges(opts: OptionsToAdoptRemoteFolderChanges | undefined): Promise<number | undefined>;
182
183
  }
183
184
  export {};
@@ -344,17 +344,59 @@ class FolderNode extends node_in_fs_1.NodeInFS {
344
344
  return nodeSet;
345
345
  }
346
346
  catch (exc) {
347
- if (exc.objNotFound && fromCurrentNodes) {
348
- await this.fixMissingChildAndThrow(exc, info);
349
- }
350
- else if (exc.failedCipherVerification) {
347
+ if (exc.failedCipherVerification) {
351
348
  exc = (0, file_1.makeFileException)('ioError', `${this.name}/${info.name}`, exc);
352
349
  }
353
- // XXX why and what ?
350
+ else if (exc.objNotFound) {
351
+ if (fromCurrentNodes) {
352
+ await this.fixMissingChildAndThrow(exc, info);
353
+ }
354
+ else {
355
+ try {
356
+ const node = await this.getNonLocal(info);
357
+ if (node) {
358
+ deferred.resolve(node);
359
+ return nodeSet;
360
+ }
361
+ else {
362
+ throw exc;
363
+ }
364
+ }
365
+ catch (exc2) {
366
+ exc = exc2;
367
+ }
368
+ }
369
+ }
354
370
  deferred.reject((0, error_1.errWithCause)(exc, `Failed to instantiate fs node '${this.name}/${info.name}'`));
355
371
  return nodeSet;
356
372
  }
357
373
  }
374
+ async getNonLocal(info) {
375
+ var _a;
376
+ const storage = this.syncedStorage();
377
+ const { objId, name, key } = info;
378
+ const status = await storage.status(objId);
379
+ const { remote, synced } = status.syncStatus();
380
+ const remoteVersion = (_a = remote === null || remote === void 0 ? void 0 : remote.latest) !== null && _a !== void 0 ? _a : synced === null || synced === void 0 ? void 0 : synced.latest;
381
+ if (!remoteVersion) {
382
+ return;
383
+ }
384
+ const src = await storage.getObjSrcOfRemoteVersion(info.objId, remoteVersion);
385
+ let node;
386
+ if (info.isFile) {
387
+ node = await file_node_1.FileNode.readNodeFromObjBytes(storage, undefined, name, objId, src, key);
388
+ }
389
+ else if (info.isFolder) {
390
+ node = await FolderNode.readNodeFromObjBytes(storage, undefined, objId, src, key);
391
+ }
392
+ else if (info.isLink) {
393
+ node = await link_node_1.LinkNode.readNodeFromObjBytes(storage, undefined, name, objId, src, key);
394
+ }
395
+ else {
396
+ throw new Error(`Unknown type of fs node`);
397
+ }
398
+ return node;
399
+ }
358
400
  getFolder(name, undefOnMissing = false) {
359
401
  return this.getNode('folder', name, undefOnMissing);
360
402
  }
@@ -377,61 +419,6 @@ class FolderNode extends node_in_fs_1.NodeInFS {
377
419
  fileExc.inconsistentStateOfFS = true;
378
420
  throw fileExc;
379
421
  }
380
- // XXX should we keep this, when merge with certain inputs will do same action
381
- // async adoptItemsFromRemoteVersion(opts: OptionsToAdoptAllRemoteItems|undefined): Promise<number|undefined> {
382
- // const { state, remote } = await this.syncStatus();
383
- // if ((state !== 'conflicting') && (state !== 'behind')) {
384
- // return;
385
- // }
386
- // const remoteVersion = versionFromRemoteBranch(remote!, opts?.remoteVersion);
387
- // if (!remoteVersion) {
388
- // throw 'something';
389
- // }
390
- // const { folderInfo: remoteState } = await this.readRemoteVersion(remoteVersion);
391
- // const synced = undefined;
392
- // return await this.doChangeWhileTrackingVersion(opts?.localVersion, async (state, newVersion) => {
393
- // const { inRemote, nameOverlaps, differentKeys } = diffNodes(state, remoteState, synced);
394
- // if (differentKeys) {
395
- // throw makeFSSyncException(this.name, {
396
- // message: `There are different keys, and implementation for it is not implemented, yet.`
397
- // });
398
- // }
399
- // const events: { event: FSEvent; childObjId: string; }[] = [];
400
- // if (!inRemote) {
401
- // return events;
402
- // }
403
- // const addedNodes = new Set<string>();
404
- // if (nameOverlaps) {
405
- // const postfix = opts?.postfixForNameOverlaps;
406
- // if ((postfix === undefined) || (postfix.length < 0)) {
407
- // // XXX better exception
408
- // throw 'something';
409
- // }
410
- // for (const itemName of nameOverlaps) {
411
- // const node = remoteState.nodes[itemName];
412
- // let newName = `${itemName}${postfix}`;
413
- // while (state.nodes[newName]) {
414
- // newName = `${newName}${postfix}`;
415
- // }
416
- // node.name = newName;
417
- // state.nodes[newName] = node;
418
- // addedNodes.add(itemName);
419
- // const { event, childObjId } = this.makeEntryAdditionEvent(newVersion, 'sync', node);
420
- // events.push({ event, childObjId });
421
- // }
422
- // }
423
- // for (const { name: itemName } of inRemote) {
424
- // if (addedNodes.has(itemName)) {
425
- // continue;
426
- // }
427
- // const node = remoteState.nodes[itemName];
428
- // state.nodes[itemName] = node;
429
- // const { event, childObjId } = this.makeEntryAdditionEvent(newVersion, 'sync', node);
430
- // events.push({ event, childObjId });
431
- // }
432
- // return events;
433
- // });
434
- // }
435
422
  /**
436
423
  * If no initial local version given, then this performs like doTransition(change) method.
437
424
  * When initial local version is given and check, exceptions are thrown if versions mismatch,
@@ -1061,7 +1048,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
1061
1048
  getStorage() {
1062
1049
  return this.storage;
1063
1050
  }
1064
- async mergeCurrentAndRemoteVersions(opts) {
1051
+ async absorbRemoteChanges(opts) {
1065
1052
  const diff = await this.diffCurrentAndRemote(opts === null || opts === void 0 ? void 0 : opts.remoteVersion);
1066
1053
  if (!diff) {
1067
1054
  return;
@@ -32,7 +32,7 @@ type OptionsToDiffFileVersions = web3n.files.OptionsToDiffFileVersions;
32
32
  type OptionsToUploadLocal = web3n.files.OptionsToUploadLocal;
33
33
  type FolderDiff = web3n.files.FolderDiff;
34
34
  type FileDiff = web3n.files.FileDiff;
35
- type OptionsToMergeFolderVersions = web3n.files.OptionsToMergeFolderVersions;
35
+ type OptionsToAdoptRemoteFolderChanges = web3n.files.OptionsToAdoptRemoteFolderChanges;
36
36
  export declare class XspFS implements WritableFS {
37
37
  readonly writable: boolean;
38
38
  name: string;
@@ -166,6 +166,7 @@ declare class V implements WritableFSVersionedAPI, N {
166
166
  declare class S implements WritableFSSyncAPI {
167
167
  private readonly n;
168
168
  constructor(n: N);
169
+ whenConnected(): Promise<void>;
169
170
  startUpload(path: string, opts?: OptionsToUploadLocal): Promise<{
170
171
  uploadVersion: number;
171
172
  uploadTaskId: number;
@@ -187,6 +188,6 @@ declare class S implements WritableFSSyncAPI {
187
188
  listRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ListingEntry[]>;
188
189
  getRemoteFileItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFile>;
189
190
  getRemoteFolderItem(path: string, remoteItemName: string, remoteVersion?: number): Promise<ReadonlyFS>;
190
- mergeFolderCurrentAndRemoteVersions(path: string, opts?: OptionsToMergeFolderVersions): Promise<number | undefined>;
191
+ absorbRemoteFolderChanges(path: string, opts?: OptionsToAdoptRemoteFolderChanges): Promise<number | undefined>;
191
192
  }
192
193
  export {};
@@ -708,6 +708,9 @@ class S {
708
708
  this.n = n;
709
709
  Object.freeze(this);
710
710
  }
711
+ whenConnected() {
712
+ return this.n.getRootIfNotClosed('').getStorage().whenConnected();
713
+ }
711
714
  async startUpload(path, opts) {
712
715
  this.n.ensureIsWritable();
713
716
  const node = await this.n.get(path);
@@ -859,9 +862,9 @@ class S {
859
862
  throw (0, file_1.makeFileException)('notDirectory', `${path}/${remoteItemName}`);
860
863
  }
861
864
  }
862
- async mergeFolderCurrentAndRemoteVersions(path, opts) {
865
+ async absorbRemoteFolderChanges(path, opts) {
863
866
  const folderNode = await this.getFolderNode(path);
864
- return await folderNode.mergeCurrentAndRemoteVersions(opts);
867
+ return await folderNode.absorbRemoteChanges(opts);
865
868
  }
866
869
  }
867
870
  Object.freeze(S.prototype);
@@ -26,6 +26,7 @@ export declare class LinkNode extends NodeInFS<LinkPersistance> {
26
26
  constructor(storage: Storage, name: string, objId: string, version: number, parentId: string | undefined, key: Uint8Array);
27
27
  static makeForNew(storage: Storage, parentId: string, name: string, key: Uint8Array): Promise<LinkNode>;
28
28
  static makeForExisting(storage: Storage, parentId: string, name: string, objId: string, key: Uint8Array): Promise<LinkNode>;
29
+ static readNodeFromObjBytes(storage: Storage, parentId: string | undefined, name: string, objId: string, src: ObjSource, key: Uint8Array): Promise<LinkNode>;
29
30
  protected setCurrentStateFrom(src: ObjSource): Promise<void>;
30
31
  getStats(flags?: VersionedReadFlags): Promise<Stats>;
31
32
  private setUpdatedState;
@@ -93,6 +93,9 @@ class LinkNode extends node_in_fs_1.NodeInFS {
93
93
  }
94
94
  static async makeForExisting(storage, parentId, name, objId, key) {
95
95
  const src = await storage.getObjSrc(objId);
96
+ return await LinkNode.readNodeFromObjBytes(storage, parentId, name, objId, src, key);
97
+ }
98
+ static async readNodeFromObjBytes(storage, parentId, name, objId, src, key) {
96
99
  const link = new LinkNode(storage, name, objId, src.version, parentId, key);
97
100
  const { params, attrs, xattrs } = await link.crypto.read(src);
98
101
  link.setUpdatedState(params, src.version, attrs, xattrs);
@@ -124,5 +124,5 @@ export declare abstract class NodeInFS<P extends NodePersistance> implements Nod
124
124
  }
125
125
  export declare function shouldReadCurrentVersion(flags: VersionedReadFlags | undefined): boolean;
126
126
  export declare function areBytesEqual(b1: Uint8Array, b2: Uint8Array): boolean;
127
- export declare function versionFromRemoteBranch(remote: SyncVersionsBranch, remoteVersion: number | undefined): number | undefined;
127
+ export declare function versionFromBranch(branch: SyncVersionsBranch, versionInBranch: number | undefined): number | undefined;
128
128
  export {};
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.NodeInFS = void 0;
20
20
  exports.shouldReadCurrentVersion = shouldReadCurrentVersion;
21
21
  exports.areBytesEqual = areBytesEqual;
22
- exports.versionFromRemoteBranch = versionFromRemoteBranch;
22
+ exports.versionFromBranch = versionFromBranch;
23
23
  /**
24
24
  * Everything in this module is assumed to be inside of a file system
25
25
  * reliance set.
@@ -550,14 +550,19 @@ class NodeInFS {
550
550
  let isCurrentLocal;
551
551
  if (state === 'behind') {
552
552
  isCurrentLocal = false;
553
+ remoteVersion = versionFromBranch(remote, remoteVersion);
553
554
  }
554
555
  else if (state === 'conflicting') {
555
556
  isCurrentLocal = true;
557
+ remoteVersion = versionFromBranch(remote, remoteVersion);
558
+ }
559
+ else if (state === 'unsynced') {
560
+ isCurrentLocal = true;
561
+ remoteVersion = versionFromBranch(synced, remoteVersion);
556
562
  }
557
563
  else {
558
564
  return;
559
565
  }
560
- remoteVersion = versionFromRemoteBranch(remote, remoteVersion);
561
566
  if (remoteVersion) {
562
567
  return { rm: false, isCurrentLocal, remoteVersion, syncedVersion: synced === null || synced === void 0 ? void 0 : synced.latest };
563
568
  }
@@ -708,23 +713,20 @@ function areBytesEqual(b1, b2) {
708
713
  }
709
714
  return true;
710
715
  }
711
- function versionFromRemoteBranch(remote, remoteVersion) {
716
+ function versionFromBranch(branch, versionInBranch) {
712
717
  var _a;
713
- if (remote.isArchived) {
714
- return;
715
- }
716
- if (remoteVersion) {
717
- if ((remoteVersion !== remote.latest)
718
- && !((_a = remote.archived) === null || _a === void 0 ? void 0 : _a.includes(remoteVersion))) {
718
+ if (versionInBranch) {
719
+ if ((versionInBranch !== branch.latest)
720
+ && !((_a = branch.archived) === null || _a === void 0 ? void 0 : _a.includes(versionInBranch))) {
719
721
  throw (0, exceptions_1.makeFSSyncException)(this.name, {
720
722
  versionMismatch: true,
721
- message: `Unknown remote version ${remoteVersion}`
723
+ message: `Unknown version in branch: ${versionInBranch}`
722
724
  });
723
725
  }
724
- return remoteVersion;
726
+ return versionInBranch;
725
727
  }
726
728
  else {
727
- return remote.latest;
729
+ return branch.latest;
728
730
  }
729
731
  }
730
732
  Object.freeze(exports);
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.errWithCause = errWithCause;
19
20
  exports.recursiveErrJSONify = recursiveErrJSONify;