core-3nweb-client-lib 0.26.1 → 0.27.3

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 (211) hide show
  1. package/build/api-defs/asmail.d.ts +1 -1
  2. package/build/api-defs/files.d.ts +281 -75
  3. package/build/core/app-files.js +7 -7
  4. package/build/core/asmail/config/common.js +2 -2
  5. package/build/core/asmail/config/index.js +2 -2
  6. package/build/core/asmail/config/published-intro-key.js +1 -1
  7. package/build/core/asmail/delivery/common.js +7 -7
  8. package/build/core/asmail/delivery/index.js +5 -5
  9. package/build/core/asmail/delivery/msg.js +4 -4
  10. package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
  11. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
  12. package/build/core/asmail/inbox/attachments/fs.js +9 -4
  13. package/build/core/asmail/inbox/cached-msgs.js +1 -1
  14. package/build/core/asmail/inbox/inbox-events.js +4 -4
  15. package/build/core/asmail/inbox/index.js +10 -10
  16. package/build/core/asmail/inbox/msg-downloader.js +1 -1
  17. package/build/core/asmail/inbox/msg-indexing.js +1 -1
  18. package/build/core/asmail/inbox/msg-on-disk.js +5 -5
  19. package/build/core/asmail/index.d.ts +3 -3
  20. package/build/core/asmail/index.js +13 -8
  21. package/build/core/asmail/key-verification.js +5 -5
  22. package/build/core/asmail/keyring/common.js +7 -6
  23. package/build/core/asmail/keyring/correspondent-keys.js +8 -7
  24. package/build/core/asmail/keyring/id-to-email-map.js +2 -1
  25. package/build/core/asmail/keyring/index.d.ts +7 -8
  26. package/build/core/asmail/keyring/index.js +15 -14
  27. package/build/core/asmail/keyring/keyring-storage.js +2 -1
  28. package/build/core/asmail/msg/opener.js +3 -3
  29. package/build/core/asmail/msg/packer.js +13 -13
  30. package/build/core/asmail/sending-params/own-params.js +2 -2
  31. package/build/core/asmail/sending-params/params-from-others.js +1 -1
  32. package/build/core/id-manager/index.d.ts +43 -0
  33. package/build/core/{id-manager.js → id-manager/index.js} +36 -114
  34. package/build/core/id-manager/key-storage.d.ts +21 -0
  35. package/build/core/id-manager/key-storage.js +96 -0
  36. package/build/core/index.d.ts +2 -1
  37. package/build/core/index.js +31 -33
  38. package/build/core/sign-in.d.ts +1 -2
  39. package/build/core/sign-in.js +8 -17
  40. package/build/core/sign-up.d.ts +2 -0
  41. package/build/core/sign-up.js +11 -10
  42. package/build/core/storage/common/json-saving.js +2 -2
  43. package/build/core/storage/common/obj-info-file.d.ts +12 -4
  44. package/build/core/storage/common/obj-info-file.js +66 -34
  45. package/build/core/storage/common/utils.d.ts +2 -0
  46. package/build/core/storage/common/utils.js +32 -0
  47. package/build/core/storage/index.d.ts +5 -17
  48. package/build/core/storage/index.js +78 -119
  49. package/build/core/storage/local/obj-files-gc.d.ts +2 -0
  50. package/build/core/storage/local/obj-files-gc.js +49 -37
  51. package/build/core/storage/local/obj-files.d.ts +4 -7
  52. package/build/core/storage/local/obj-files.js +7 -10
  53. package/build/core/storage/local/obj-status.d.ts +12 -6
  54. package/build/core/storage/local/obj-status.js +24 -9
  55. package/build/core/storage/local/storage.d.ts +10 -7
  56. package/build/core/storage/local/storage.js +29 -18
  57. package/build/core/storage/synced/downloader.js +1 -1
  58. package/build/core/storage/synced/obj-files-gc.d.ts +1 -0
  59. package/build/core/storage/synced/obj-files-gc.js +76 -39
  60. package/build/core/storage/synced/obj-files.d.ts +50 -36
  61. package/build/core/storage/synced/obj-files.js +201 -162
  62. package/build/core/storage/synced/obj-status.d.ts +99 -86
  63. package/build/core/storage/synced/obj-status.js +520 -251
  64. package/build/core/storage/synced/remote-events.d.ts +11 -12
  65. package/build/core/storage/synced/remote-events.js +73 -56
  66. package/build/core/storage/synced/storage.d.ts +24 -10
  67. package/build/core/storage/synced/storage.js +147 -47
  68. package/build/core/storage/synced/upload-header-file.d.ts +4 -0
  69. package/build/core/storage/synced/upload-header-file.js +64 -0
  70. package/build/core/storage/synced/upsyncer.d.ts +12 -7
  71. package/build/core/storage/synced/upsyncer.js +210 -280
  72. package/build/core/storage/system-folders/apps-data.d.ts +16 -0
  73. package/build/core/storage/system-folders/apps-data.js +110 -0
  74. package/build/core/storage/system-folders/index.d.ts +18 -0
  75. package/build/core/storage/system-folders/index.js +77 -0
  76. package/build/core-ipc/common-caps.js +3 -3
  77. package/build/core-ipc/generic.js +8 -8
  78. package/build/core-ipc/startup-caps.js +2 -2
  79. package/build/cryptors.js +6 -2
  80. package/build/ipc-via-protobuf/asmail-cap.js +58 -57
  81. package/build/ipc-via-protobuf/bytes.js +16 -17
  82. package/build/ipc-via-protobuf/connector-clients-side.d.ts +1 -0
  83. package/build/ipc-via-protobuf/connector-clients-side.js +14 -15
  84. package/build/ipc-via-protobuf/connector-services-side.js +10 -10
  85. package/build/ipc-via-protobuf/connector.js +4 -4
  86. package/build/ipc-via-protobuf/file.d.ts +48 -12
  87. package/build/ipc-via-protobuf/file.js +474 -126
  88. package/build/ipc-via-protobuf/fs.d.ts +8 -0
  89. package/build/ipc-via-protobuf/fs.js +577 -142
  90. package/build/ipc-via-protobuf/log-cap.js +2 -2
  91. package/build/ipc-via-protobuf/mailerid.js +3 -3
  92. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
  93. package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
  94. package/build/ipc-via-protobuf/startup-cap.js +21 -21
  95. package/build/ipc-via-protobuf/storage-cap.js +12 -12
  96. package/build/ipc.js +7 -2
  97. package/build/lib-client/3nstorage/exceptions.d.ts +16 -1
  98. package/build/lib-client/3nstorage/exceptions.js +21 -3
  99. package/build/lib-client/3nstorage/service.d.ts +21 -3
  100. package/build/lib-client/3nstorage/service.js +128 -46
  101. package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
  102. package/build/lib-client/3nstorage/util/file-based-json.js +3 -2
  103. package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
  104. package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
  105. package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
  106. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +44 -19
  107. package/build/lib-client/3nstorage/xsp-fs/common.js +30 -19
  108. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
  109. package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
  110. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
  111. package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
  112. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
  113. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +32 -13
  114. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +752 -192
  115. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
  116. package/build/lib-client/3nstorage/xsp-fs/fs.js +236 -119
  117. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
  118. package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
  119. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -29
  120. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +232 -127
  121. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
  122. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
  123. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
  124. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
  125. package/build/lib-client/3nweb-signup.js +4 -4
  126. package/build/lib-client/asmail/recipient.js +15 -15
  127. package/build/lib-client/asmail/sender.js +22 -22
  128. package/build/lib-client/asmail/service-config.js +3 -3
  129. package/build/lib-client/cryptor/cryptor-in-worker.js +18 -16
  130. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  131. package/build/lib-client/cryptor/cryptor.js +4 -2
  132. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  133. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  134. package/build/lib-client/cryptor/in-proc-wasm.js +6 -6
  135. package/build/lib-client/cryptor/worker-js.js +2 -2
  136. package/build/lib-client/cryptor/worker-wasm.js +2 -2
  137. package/build/lib-client/files-select.js +1 -1
  138. package/build/lib-client/files.d.ts +1 -1
  139. package/build/lib-client/files.js +71 -6
  140. package/build/lib-client/fs-collection.js +1 -1
  141. package/build/lib-client/fs-sync-utils.d.ts +5 -0
  142. package/build/lib-client/fs-sync-utils.js +61 -0
  143. package/build/lib-client/fs-view.d.ts +14 -0
  144. package/build/lib-client/fs-view.js +33 -0
  145. package/build/lib-client/key-derivation.js +1 -1
  146. package/build/lib-client/local-files/dev-file-sink.js +9 -9
  147. package/build/lib-client/local-files/dev-file-src.js +2 -2
  148. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  149. package/build/lib-client/local-files/device-fs.js +56 -54
  150. package/build/lib-client/logging/log-to-file.d.ts +1 -1
  151. package/build/lib-client/logging/log-to-file.js +7 -7
  152. package/build/lib-client/mailer-id/login.js +7 -7
  153. package/build/lib-client/mailer-id/provisioner.js +12 -12
  154. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -3
  155. package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
  156. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
  157. package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
  158. package/build/lib-client/request-utils.d.ts +1 -0
  159. package/build/lib-client/request-utils.js +13 -13
  160. package/build/lib-client/server-events.d.ts +3 -3
  161. package/build/lib-client/server-events.js +9 -8
  162. package/build/lib-client/service-locator.js +10 -10
  163. package/build/lib-client/user-with-mid-session.d.ts +2 -1
  164. package/build/lib-client/user-with-mid-session.js +14 -8
  165. package/build/lib-client/user-with-pkl-session.js +25 -25
  166. package/build/lib-client/ws-utils.js +2 -2
  167. package/build/lib-common/async-cryptor-wrap.js +4 -4
  168. package/build/lib-common/async-fs-node.d.ts +5 -3
  169. package/build/lib-common/async-fs-node.js +17 -17
  170. package/build/lib-common/byte-streaming/pipe.js +1 -1
  171. package/build/lib-common/byte-streaming/wrapping.js +13 -13
  172. package/build/lib-common/canonical-address.js +1 -1
  173. package/build/lib-common/exceptions/error.d.ts +1 -0
  174. package/build/lib-common/exceptions/error.js +7 -6
  175. package/build/lib-common/exceptions/file.d.ts +4 -2
  176. package/build/lib-common/exceptions/file.js +24 -54
  177. package/build/lib-common/ipc/generic-ipc.js +5 -4
  178. package/build/lib-common/ipc/ws-ipc.js +2 -2
  179. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  180. package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
  181. package/build/lib-common/objs-on-disk/file-layout.js +130 -12
  182. package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
  183. package/build/lib-common/objs-on-disk/obj-file.js +96 -35
  184. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  185. package/build/lib-common/objs-on-disk/utils.js +3 -3
  186. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
  187. package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
  188. package/build/lib-common/processes/labelled-exec-pools.js +1 -1
  189. package/build/lib-common/processes/pressure.js +2 -2
  190. package/build/lib-common/processes/synced.js +1 -1
  191. package/build/lib-common/processes/timeout.js +2 -2
  192. package/build/lib-common/random-node.js +7 -7
  193. package/build/lib-common/service-api/3nstorage/owner.d.ts +101 -42
  194. package/build/lib-common/service-api/3nstorage/owner.js +83 -40
  195. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  196. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  197. package/build/lib-common/timed-cache.d.ts +1 -0
  198. package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
  199. package/build/lib-common/timed-non-weak-cache.js +11 -0
  200. package/build/lib-common/utils-for-observables.js +4 -4
  201. package/build/lib-common/weak-cache.d.ts +1 -0
  202. package/build/lib-common/weak-cache.js +12 -1
  203. package/build/lib-index.d.ts +2 -1
  204. package/build/lib-index.js +10 -7
  205. package/build/protos/asmail.proto.js +12955 -7496
  206. package/build/protos/file.proto.js +4867 -2744
  207. package/build/protos/fs.proto.js +9227 -3768
  208. package/package.json +7 -5
  209. package/protos/file.proto +91 -19
  210. package/protos/fs.proto +107 -8
  211. package/build/core/id-manager.d.ts +0 -46
@@ -21,109 +21,201 @@ const path_1 = require("path");
21
21
  const exceptions_1 = require("../../../lib-client/3nstorage/exceptions");
22
22
  const json_saving_1 = require("../common/json-saving");
23
23
  const obj_info_file_1 = require("../common/obj-info-file");
24
- const json_utils_1 = require("../../../lib-common/json-utils");
24
+ const assert_1 = require("../../../lib-common/assert");
25
+ const file_1 = require("../../../lib-common/exceptions/file");
26
+ function makeVersions() {
27
+ return {
28
+ baseToDiff: {},
29
+ diffToBase: {},
30
+ };
31
+ }
32
+ function makeObjStatusInfo(objId) {
33
+ return {
34
+ objId,
35
+ remote: makeVersions()
36
+ };
37
+ }
38
+ function syncStateOf({ local, synced, remote }) {
39
+ const syncedIsCurrent = isSyncedCurrentWithRemote(synced, remote);
40
+ if (local) {
41
+ switch (syncedIsCurrent) {
42
+ case undefined:
43
+ case true:
44
+ return ((local.isArchived && (synced === null || synced === void 0 ? void 0 : synced.isArchived)) ?
45
+ 'synced' : 'unsynced');
46
+ case false:
47
+ return 'conflicting';
48
+ }
49
+ }
50
+ else {
51
+ switch (syncedIsCurrent) {
52
+ case undefined:
53
+ return 'unsynced';
54
+ case true:
55
+ return 'synced';
56
+ case false:
57
+ return 'behind';
58
+ }
59
+ }
60
+ }
61
+ function isSyncedCurrentWithRemote(synced, remote) {
62
+ if (synced) {
63
+ return ((synced.version === remote.current)
64
+ && (synced.isArchived === remote.isArchived));
65
+ }
66
+ else {
67
+ return (isRemoteEmpty(remote) ? undefined : false);
68
+ }
69
+ }
70
+ function isRemoteEmpty(remote) {
71
+ return (0, obj_info_file_1.isEmptyVersions)(remote) && !remote.isArchived;
72
+ }
73
+ function nonGarbageWithMaxVer(v) {
74
+ return {
75
+ gcMaxVer: v.current,
76
+ nonGarbage: (0, obj_info_file_1.nonGarbageVersionsIn)(v)
77
+ };
78
+ }
79
+ function identifyNonGarbage(status) {
80
+ var _a;
81
+ let local = undefined;
82
+ let uploadVersion = undefined;
83
+ if (status.local) {
84
+ local = nonGarbageWithMaxVer(status.local);
85
+ }
86
+ if (status.upload) {
87
+ const { localVersion } = status.upload;
88
+ if (status.local.current !== localVersion) {
89
+ (0, obj_info_file_1.addWithBasesTo)(local.nonGarbage, localVersion, status.local);
90
+ }
91
+ if (status.upload.type === 'new-version') {
92
+ uploadVersion = status.upload.uploadVersion;
93
+ }
94
+ }
95
+ const remote = nonGarbageWithMaxVer(status.remote);
96
+ if ((_a = status.synced) === null || _a === void 0 ? void 0 : _a.version) {
97
+ remote.nonGarbage.add(status.synced.version);
98
+ if (status.synced.base) {
99
+ (0, obj_info_file_1.addWithBasesTo)(remote.nonGarbage, status.synced.base, status.remote);
100
+ }
101
+ }
102
+ return { local, remote, uploadVersion };
103
+ }
25
104
  exports.STATUS_FILE_NAME = 'status';
26
105
  class ObjStatus {
27
106
  constructor(objFolder, status, logError) {
28
107
  this.objFolder = objFolder;
29
108
  this.status = status;
30
109
  this.logError = logError;
31
- this.saveProc = new json_saving_1.JSONSavingProc(path_1.join(this.objFolder, exports.STATUS_FILE_NAME), () => this.status);
32
- Object.freeze(this);
110
+ this.saveProc = new json_saving_1.JSONSavingProc((0, path_1.join)(this.objFolder, exports.STATUS_FILE_NAME), () => this.status);
111
+ this.updateStateIndicator();
112
+ Object.seal(this);
33
113
  }
34
114
  static async readFrom(objFolder, objId, logError) {
35
115
  const status = await readAndCheckStatus(objFolder, objId);
36
116
  return new ObjStatus(objFolder, status, logError);
37
117
  }
38
118
  static async makeNew(objFolder, objId, logError) {
39
- const status = {
40
- objId,
41
- sync: {
42
- state: 'unsynced'
43
- },
44
- versions: {
45
- baseToDiff: {},
46
- diffToBase: {},
47
- }
48
- };
119
+ const status = makeObjStatusInfo(objId);
49
120
  const s = new ObjStatus(objFolder, status, logError);
50
121
  await s.triggerSaveProc();
51
122
  return s;
52
123
  }
53
124
  static async makeForDownloadedVersion(objFolder, objId, version, currentRemote, logError) {
54
- const status = {
55
- objId,
56
- sync: {
57
- state: 'synced',
58
- remote: currentRemote,
59
- latest: currentRemote,
60
- },
61
- versions: {
62
- current: version,
63
- baseToDiff: {},
64
- diffToBase: {}
65
- }
66
- };
125
+ const status = makeObjStatusInfo(objId);
126
+ status.remote.current = currentRemote;
127
+ status.synced = { version: currentRemote };
128
+ if (currentRemote > version) {
129
+ status.remote.archived = [version];
130
+ }
131
+ else if (currentRemote !== version) {
132
+ throw new Error(`Downloaded version can't be greater than current remote`);
133
+ }
67
134
  const s = new ObjStatus(objFolder, status, logError);
68
135
  await s.triggerSaveProc();
69
136
  return s;
70
137
  }
71
138
  static async fileShowsObjNotInSyncedState(objFolder, objId) {
72
139
  const status = await readAndCheckStatus(objFolder, objId);
73
- return (status.sync.state !== 'synced');
140
+ return (syncStateOf(status) !== 'synced');
74
141
  }
75
- isArchived() {
76
- return !!this.status.isArchived;
142
+ static async fileShowsObjNeedsRemovalOnRemote(objFolder, objId) {
143
+ const status = await readAndCheckStatus(objFolder, objId);
144
+ const upload = status.upload;
145
+ return (((upload === null || upload === void 0 ? void 0 : upload.type) === 'removal') && !upload.isPostponed);
77
146
  }
78
- getCurrentVersionOrThrow() {
79
- if (typeof this.status.versions.current !== 'number') {
80
- throw new Error(`Object ${this.status.objId} has no current version.`);
81
- }
82
- return this.status.versions.current;
147
+ needsRemovalOnRemote() {
148
+ const upload = this.status.upload;
149
+ return (((upload === null || upload === void 0 ? void 0 : upload.type) === 'removal') && !upload.isPostponed);
83
150
  }
84
- getNonGarbageVersions() {
85
- const versions = this.status.versions;
86
- const nonGarbage = obj_info_file_1.nonGarbageVersionsIn(versions);
87
- if (this.status.syncTasks) {
88
- const tasks = this.status.syncTasks;
89
- if (tasks.current) {
90
- obj_info_file_1.addWithBasesTo(nonGarbage, nonGarbageVersionInTask(tasks.current), versions);
91
- }
92
- for (const t of tasks.queued) {
93
- obj_info_file_1.addWithBasesTo(nonGarbage, nonGarbageVersionInTask(t), versions);
94
- }
151
+ async clearPostponeFlagInRemovalOnRemote() {
152
+ const { upload } = this.status;
153
+ if (!upload) {
154
+ return false;
95
155
  }
96
- return {
97
- nonGarbage,
98
- gcMaxVer: versions.current
99
- };
156
+ if (upload.type !== 'removal') {
157
+ throw new Error(`No upload removal in obj status`);
158
+ }
159
+ upload.isPostponed = false;
160
+ await this.triggerSaveProc();
161
+ return true;
100
162
  }
101
- isRemoteVersionGreaterOrEqualTo(newRemoteVersion) {
102
- return ((typeof this.status.sync.remote === 'number') ?
103
- (this.status.sync.remote >= newRemoteVersion) : false);
163
+ updateStateIndicator() {
164
+ this.stateIndicator = syncStateOf(this.status);
104
165
  }
105
- isDeletedOnRemote() {
106
- return !!this.status.sync.deletedOnRemote;
166
+ isArchived() {
167
+ var _a;
168
+ return !!((_a = this.status.local) === null || _a === void 0 ? void 0 : _a.isArchived);
107
169
  }
108
- syncedVersionGreaterOrEqual(version) {
109
- return ((typeof this.status.sync.latest !== 'number') ?
110
- false : (version <= this.status.sync.latest));
170
+ getCurrentLocalOrSynced() {
171
+ var _a, _b;
172
+ const state = this.stateIndicator;
173
+ const current = (((state === 'unsynced') || (state === 'conflicting')) ?
174
+ (_a = this.status.local) === null || _a === void 0 ? void 0 : _a.current : (_b = this.status.synced) === null || _b === void 0 ? void 0 : _b.version);
175
+ if (current) {
176
+ return current;
177
+ }
178
+ else {
179
+ throw (0, exceptions_1.makeStorageException)({
180
+ objNotFound: true,
181
+ message: 'Current version is not found'
182
+ });
183
+ }
111
184
  }
112
- async removeCurrentVersion(verObjs) {
113
- this.status.isArchived = true;
114
- const current = obj_info_file_1.rmCurrentVersionIn(this.status.versions);
115
- if (typeof current === 'number') {
116
- verObjs.delete(current);
185
+ getNonGarbageVersions() {
186
+ return identifyNonGarbage(this.status);
187
+ }
188
+ async removeCurrentVersion() {
189
+ let { local, synced, remote, upload } = this.status;
190
+ if ((synced === null || synced === void 0 ? void 0 : synced.isArchived) || (local === null || local === void 0 ? void 0 : local.isArchived)) {
191
+ return;
117
192
  }
118
- this.addRemoveCurrentToQueue();
119
- await this.triggerSaveProc().catch((exc) => {
120
- if (exc.notFound && this.status.isArchived) {
193
+ if (upload) {
194
+ if (upload.type === 'removal') {
121
195
  return;
122
196
  }
123
197
  else {
124
- throw exc;
198
+ throw (0, file_1.makeFileException)('concurrentUpdate', 'obj-status', `Upload is in progress`);
125
199
  }
126
- });
200
+ }
201
+ if (!remote.isArchived && remote.current) {
202
+ this.status.upload = {
203
+ type: 'removal',
204
+ localVersion: ((local === null || local === void 0 ? void 0 : local.current) || (synced === null || synced === void 0 ? void 0 : synced.version)),
205
+ isPostponed: true
206
+ };
207
+ upload = this.status.upload;
208
+ }
209
+ if (local) {
210
+ local.isArchived = true;
211
+ local.current = undefined;
212
+ }
213
+ else {
214
+ this.status.local = makeVersions();
215
+ this.status.local.isArchived = true;
216
+ }
217
+ this.updateStateIndicator();
218
+ await this.triggerSaveProc().catch(skipNotFoundExc);
127
219
  }
128
220
  async triggerSaveProc(captureErrors = false, logErr = false) {
129
221
  try {
@@ -140,256 +232,433 @@ class ObjStatus {
140
232
  }
141
233
  }
142
234
  }
143
- async setDeletedOnRemote() {
144
- this.status.sync.deletedOnRemote = true;
145
- await this.triggerSaveProc();
146
- }
147
- async setRemoteVersion(version) {
148
- if (this.status.sync.remote >= version) {
149
- return;
235
+ recordUploadStart(info) {
236
+ var _a;
237
+ if (this.status.upload) {
238
+ const upload = this.status.upload;
239
+ throw (0, exceptions_1.makeFSSyncException)('obj-status', {
240
+ alreadyUploading: true,
241
+ message: `Status already has upload of version ${upload.uploadVersion} and can't start another upload with version ${info.uploadVersion}`
242
+ });
150
243
  }
151
- this.status.sync.remote = version;
152
- if (this.status.sync.state === 'synced') {
153
- if (this.status.versions.current < this.status.sync.remote) {
154
- this.status.sync.state = 'behind';
155
- }
244
+ if (info.localVersion === ((_a = this.status.local) === null || _a === void 0 ? void 0 : _a.current)) {
245
+ this.status.upload = info;
246
+ return this.triggerSaveProc();
156
247
  }
157
- else if (this.status.sync.state === 'unsynced') {
158
- this.status.sync.state = 'conflicting';
248
+ else {
249
+ throw (0, exceptions_1.makeFSSyncException)('obj-status', {
250
+ localVersion: info.localVersion,
251
+ versionNotFound: true
252
+ });
159
253
  }
160
- await this.triggerSaveProc();
161
254
  }
162
- async markVersionSynced(version) {
163
- if (!this.status.sync.latest
164
- || (this.status.sync.latest < version)) {
165
- this.status.sync.latest = version;
166
- if (this.status.versions.current === version) {
167
- this.status.sync.state = 'synced';
168
- }
169
- await this.triggerSaveProc();
255
+ recordUploadInterimState(info) {
256
+ var _a;
257
+ if (((_a = this.status.upload) === null || _a === void 0 ? void 0 : _a.type) !== 'new-version') {
258
+ throw new Error(`No new version upload in object status`);
259
+ }
260
+ if (this.status.upload.uploadVersion === info.uploadVersion) {
261
+ this.status.upload = info;
262
+ return this.triggerSaveProc();
263
+ }
264
+ else {
265
+ throw new Error(`Upload versions don't match`);
170
266
  }
171
267
  }
172
- async setUnsyncedCurrentVersion(version, baseVer) {
173
- obj_info_file_1.setCurrentVersionIn(this.status.versions, version, baseVer);
174
- this.status.sync.state = 'unsynced';
175
- await this.triggerSaveProc();
176
- }
177
- /**
178
- * This method ignores remote conflicting versions.
179
- * @param version
180
- */
181
- isVersionSynced(version) {
182
- if (this.status.versions.current === undefined) {
183
- return false;
268
+ recordUploadCancellation(info) {
269
+ var _a;
270
+ if (((_a = this.status.upload) === null || _a === void 0 ? void 0 : _a.type) !== 'new-version') {
271
+ throw new Error(`No upload in object status`);
184
272
  }
185
- if (this.status.sync.state == 'synced') {
186
- return true;
273
+ if (this.status.upload.uploadVersion === info.uploadVersion) {
274
+ this.status.upload = undefined;
275
+ return this.triggerSaveProc();
187
276
  }
188
- if (this.status.sync.latest === undefined) {
189
- return false;
277
+ else {
278
+ throw new Error(`Upload versions don't match`);
190
279
  }
191
- return (this.status.sync.latest >= version);
192
280
  }
193
- isVersionArchived(version) {
194
- if (!this.status.versions.archived) {
195
- return false;
281
+ recordUploadCompletion(localVersion, uploadVersion) {
282
+ const { local, synced, remote, upload } = this.status;
283
+ if (((upload === null || upload === void 0 ? void 0 : upload.type) !== 'new-version')
284
+ || (upload.uploadVersion !== uploadVersion)) {
285
+ throw new Error(`Upload versions don't match`);
196
286
  }
197
- return this.status.versions.archived.includes(version);
198
- }
199
- queueTask(t) {
200
- if (t.type === 'upload') {
201
- this.addUploadToQueue(t);
287
+ const syncedBase = upload.baseVersion;
288
+ if (!remote.current || (remote.current <= uploadVersion)) {
289
+ (0, obj_info_file_1.setCurrentVersionIn)(remote, uploadVersion, syncedBase);
202
290
  }
203
- else if (t.type === 'removal') {
204
- if (t.currentVersion) {
205
- throw new Error(`Removal of current task needs other method`);
291
+ if (synced) {
292
+ synced.version = uploadVersion;
293
+ if (synced.base && (synced.base !== syncedBase)) {
294
+ (0, obj_info_file_1.rmNonArchVersionsIn)(remote, synced.base);
206
295
  }
207
- else if (t.archivedVersions) {
208
- this.addRemoveArchivedToQueue(t.archivedVersions);
209
- }
210
- }
211
- else if (t.type === 'archiving') {
212
- this.addArchivalToQueue(t);
296
+ synced.base = syncedBase;
213
297
  }
214
298
  else {
215
- throw new Error(`Unsupported upsync task type`);
299
+ this.status.synced = { version: uploadVersion, base: syncedBase };
216
300
  }
217
- }
218
- addUploadToQueue(u) {
219
- if (!this.status.syncTasks) {
220
- this.status.syncTasks = { queued: [u] };
301
+ if (local.current === localVersion) {
302
+ this.status.local = undefined;
221
303
  }
222
- else {
223
- const q = this.status.syncTasks.queued;
224
- const last = lastIn(q);
225
- if (last) {
226
- if (last.type === 'upload') {
227
- if (!this.isVersionArchived(last.version)) {
228
- if (last.createObj) {
229
- u.createObj = true;
230
- }
231
- q[q.length - 1] = u;
232
- }
233
- else {
234
- q.push(u);
235
- }
236
- }
237
- else if (last.type === 'archiving') {
238
- q.push(u);
239
- }
240
- else if ((last.type === 'removal') && last.archivedVersions) {
241
- q.push(u);
242
- }
243
- }
244
- else {
245
- q.push(u);
246
- }
304
+ this.status.upload = undefined;
305
+ this.updateStateIndicator();
306
+ return this.triggerSaveProc();
307
+ }
308
+ async recordArchVersionRemoval(version) {
309
+ if ((0, obj_info_file_1.rmArchVersionFrom)(this.status.remote, version)) {
310
+ return this.triggerSaveProc();
247
311
  }
248
- this.triggerSaveProc(true);
249
312
  }
250
- addRemoveCurrentToQueue() {
251
- const r = { type: 'removal', currentVersion: true };
252
- if (this.status.syncTasks) {
253
- const q = this.status.syncTasks.queued;
254
- const last = lastIn(q);
255
- if (last) {
256
- if (last.type === 'archiving') {
257
- q.push(r);
258
- }
259
- else if (last.type === 'upload') {
260
- if (this.isVersionArchived(last.version)) {
261
- q.push(r);
262
- }
263
- else if (this.status.sync.latest
264
- || this.status.syncTasks.current) {
265
- q[q.length - 1] = r;
266
- }
267
- else {
268
- q.splice(q.length - 1, 1);
269
- this.addRemoveCurrentToQueue();
270
- return;
271
- }
272
- }
273
- }
274
- else if (this.status.sync.latest
275
- || this.status.syncTasks.current) {
276
- q.push(r);
277
- }
278
- else {
279
- this.status.syncTasks = undefined;
280
- }
313
+ async recordVersionArchival(version) {
314
+ if ((0, obj_info_file_1.addArchived)(this.status.remote, version)) {
315
+ return this.triggerSaveProc();
281
316
  }
282
- else {
283
- if (this.status.sync.latest) {
284
- this.status.syncTasks = { queued: [r] };
285
- }
317
+ }
318
+ async recordRemoteRemoval() {
319
+ const { local, synced, remote } = this.status;
320
+ if ((local === null || local === void 0 ? void 0 : local.isArchived) || (synced === null || synced === void 0 ? void 0 : synced.isArchived)) {
321
+ return;
286
322
  }
323
+ remote.isArchived = true;
324
+ (0, obj_info_file_1.rmCurrentVersionIn)(remote);
325
+ this.updateStateIndicator();
326
+ return this.triggerSaveProc();
287
327
  }
288
- addRemoveArchivedToQueue(archVer) {
289
- const r = { type: 'removal', archivedVersions: archVer };
290
- if (this.status.syncTasks) {
291
- this.status.syncTasks.queued.push(r);
328
+ async recordRemoteRemovalCompletion() {
329
+ var _a;
330
+ const { remote, upload, synced } = this.status;
331
+ if ((_a = this.status.synced) === null || _a === void 0 ? void 0 : _a.isArchived) {
332
+ return;
292
333
  }
293
- else {
294
- this.status.syncTasks = { queued: [r] };
334
+ if ((upload === null || upload === void 0 ? void 0 : upload.type) !== 'removal') {
335
+ throw new Error(`Upload of removal is not in status`);
295
336
  }
296
- this.triggerSaveProc(true);
297
- }
298
- addArchivalToQueue(a) {
299
- if (!this.status.syncTasks) {
300
- this.status.syncTasks = { queued: [a] };
337
+ (0, obj_info_file_1.rmCurrentVersionIn)(remote);
338
+ remote.isArchived = true;
339
+ if (synced) {
340
+ synced.isArchived = true;
341
+ synced.version = undefined;
342
+ synced.base = undefined;
301
343
  }
302
344
  else {
303
- this.status.syncTasks.queued.push(a);
345
+ this.status.synced = { isArchived: true };
304
346
  }
305
- this.triggerSaveProc(true);
347
+ this.status.local = undefined;
348
+ this.status.upload = undefined;
349
+ this.updateStateIndicator();
350
+ return this.triggerSaveProc();
306
351
  }
307
- async getTaskForProcessing() {
308
- const syncTasks = this.status.syncTasks;
309
- if (!syncTasks) {
352
+ async recordRemoteChange(version) {
353
+ const { synced, remote, upload } = this.status;
354
+ if (((upload === null || upload === void 0 ? void 0 : upload.type) === 'new-version')
355
+ && (upload.uploadVersion === version)) {
310
356
  return;
311
357
  }
312
- if (syncTasks.current) {
313
- return syncTasks.current;
358
+ if ((synced === null || synced === void 0 ? void 0 : synced.version) && (synced.version >= version)) {
359
+ return;
360
+ }
361
+ remote.current = version;
362
+ this.updateStateIndicator();
363
+ return this.triggerSaveProc();
364
+ }
365
+ async recordStatusFromServer({ archived, current }) {
366
+ const remote = this.status.remote;
367
+ let changedCurrent = false;
368
+ if (current) {
369
+ if (!remote.current) {
370
+ remote.current = current;
371
+ changedCurrent = true;
372
+ }
373
+ else if (remote.current < current) {
374
+ (0, obj_info_file_1.rmCurrentVersionIn)(remote);
375
+ remote.current = current;
376
+ changedCurrent = true;
377
+ }
378
+ }
379
+ else if (remote.current) {
380
+ (0, obj_info_file_1.rmCurrentVersionIn)(remote);
381
+ remote.isArchived = true;
382
+ changedCurrent = true;
314
383
  }
315
- syncTasks.current = syncTasks.queued.shift();
316
- if (syncTasks.current) {
384
+ const rmArchived = removeArchVersionsNotInList(remote, archived);
385
+ const addedArchived = addArchVersionsFromList(remote, archived);
386
+ if (rmArchived || addedArchived || changedCurrent) {
387
+ this.updateStateIndicator();
317
388
  await this.triggerSaveProc();
318
389
  }
319
- return syncTasks.current;
320
390
  }
321
- glanceOnNextTask() {
322
- const syncTasks = this.status.syncTasks;
323
- if (!syncTasks) {
391
+ /**
392
+ * When given object version is a diff on some base, this method returns
393
+ * a whole trace of local base versions up to synced one.
394
+ * Local bases, if present, are return in an array with highest version
395
+ * first.
396
+ * This returns undefined, when given object version is not a diff.
397
+ * @param version that is local, for which we want to get base versions, if
398
+ * it is a diff version.
399
+ */
400
+ baseOfLocalVersion(version) {
401
+ (0, assert_1.assert)(!!this.status.local);
402
+ const local = this.status.local;
403
+ (0, assert_1.assert)((0, obj_info_file_1.isVersionIn)(version, local));
404
+ let base = local.diffToBase[version];
405
+ if (!base) {
324
406
  return;
325
407
  }
326
- if (syncTasks.current) {
327
- return syncTasks.current;
408
+ if ((0, obj_info_file_1.isVersionIn)(base, this.status.remote)) {
409
+ return { syncedBase: base };
410
+ }
411
+ const localBases = [];
412
+ do {
413
+ localBases.push(base);
414
+ base = local.diffToBase[base];
415
+ } while (base);
416
+ const lastBase = localBases[localBases.length - 1];
417
+ if ((0, obj_info_file_1.isVersionIn)(lastBase, this.status.remote)) {
418
+ return {
419
+ localBases: localBases.slice(0, localBases.length - 1),
420
+ syncedBase: lastBase
421
+ };
328
422
  }
329
- else if (syncTasks.queued.length > 0) {
330
- return syncTasks.queued[0];
423
+ else {
424
+ return { localBases };
331
425
  }
332
426
  }
333
- async recordInterimStateOfCurrentTask(t) {
334
- const syncTasks = this.status.syncTasks;
335
- if (!syncTasks) {
336
- throw new Error(`This method is called too early.`);
427
+ async setLocalCurrentVersion(version, baseVer) {
428
+ if (!this.status.local) {
429
+ this.status.local = makeVersions();
337
430
  }
338
- if (syncTasks.current === t) {
339
- await this.triggerSaveProc();
431
+ (0, obj_info_file_1.setCurrentVersionIn)(this.status.local, version, baseVer);
432
+ this.updateStateIndicator();
433
+ await this.triggerSaveProc();
434
+ }
435
+ listVersions() {
436
+ var _a;
437
+ const { local, synced, remote } = this.status;
438
+ switch (this.stateIndicator) {
439
+ case 'unsynced':
440
+ case 'conflicting':
441
+ (0, assert_1.assert)(!!local);
442
+ return {
443
+ current: local.current,
444
+ archived: ((synced === null || synced === void 0 ? void 0 : synced.version) ?
445
+ versionsToBranch(remote, synced.version, false).archived :
446
+ undefined)
447
+ };
448
+ case 'synced':
449
+ case 'behind':
450
+ (0, assert_1.assert)(!!synced);
451
+ return {
452
+ current: synced.version,
453
+ archived: ((synced === null || synced === void 0 ? void 0 : synced.version) ?
454
+ versionsToBranch(remote, synced.version, false).archived :
455
+ (_a = remote.archived) === null || _a === void 0 ? void 0 : _a.slice())
456
+ };
457
+ default:
458
+ throw new Error(`Unimplemented state ${this.stateIndicator}`);
459
+ }
460
+ }
461
+ async archiveCurrentVersion() {
462
+ const { synced, remote } = this.status;
463
+ (0, assert_1.assert)(!!(synced === null || synced === void 0 ? void 0 : synced.version));
464
+ (0, obj_info_file_1.addArchived)(remote, synced.version);
465
+ await this.triggerSaveProc();
466
+ }
467
+ absorbLocalVersionBase(version, localBase) {
468
+ (0, assert_1.assert)(!!this.status.local);
469
+ const local = this.status.local;
470
+ (0, assert_1.assert)(local.diffToBase[version] === localBase);
471
+ const lowerBase = local.diffToBase[localBase];
472
+ if (localBase) {
473
+ local.diffToBase[version] = lowerBase;
474
+ local.baseToDiff[lowerBase] = version;
340
475
  }
341
476
  else {
342
- throw new Error(`Can save interim state of a current task only`);
477
+ delete local.diffToBase[version];
343
478
  }
479
+ delete local.diffToBase[localBase];
480
+ delete local.baseToDiff[localBase];
481
+ return this.triggerSaveProc();
344
482
  }
345
- async recordTaskCompletion(t) {
346
- const syncTasks = this.status.syncTasks;
347
- if (!syncTasks) {
348
- throw new Error(`This method is called too early.`);
483
+ latestSyncedVersion() {
484
+ var _a;
485
+ return (_a = this.status.synced) === null || _a === void 0 ? void 0 : _a.version;
486
+ }
487
+ syncStatus() {
488
+ const { remote, synced } = splitVersionsIntoBranches(this.status.remote, this.status.synced);
489
+ return {
490
+ state: this.stateIndicator,
491
+ local: localVersionFromStatus(this.status.local),
492
+ remote,
493
+ synced
494
+ };
495
+ }
496
+ neverUploaded() {
497
+ const synced = this.status.synced;
498
+ return (!(synced === null || synced === void 0 ? void 0 : synced.version) && !(synced === null || synced === void 0 ? void 0 : synced.isArchived));
499
+ }
500
+ versionBeforeUnsyncedRemoval() {
501
+ var _a;
502
+ if ((this.stateIndicator !== 'synced')
503
+ && ((_a = this.status.local) === null || _a === void 0 ? void 0 : _a.isArchived)
504
+ && this.status.upload
505
+ && (this.status.upload.type === 'removal')) {
506
+ return this.status.upload.localVersion;
349
507
  }
350
- if (syncTasks.current === t) {
351
- if (syncTasks.queued.length > 0) {
352
- syncTasks.current = undefined;
508
+ }
509
+ async adoptRemoteVersion(version, dropLocalVer = false) {
510
+ var _a;
511
+ const { local, remote } = this.status;
512
+ if (this.stateIndicator !== 'behind') {
513
+ if (this.stateIndicator === 'synced') {
514
+ return;
515
+ }
516
+ else if (!dropLocalVer) {
517
+ throw (0, exceptions_1.makeFSSyncException)('', {
518
+ localVersion: local === null || local === void 0 ? void 0 : local.current,
519
+ remoteVersion: remote.current,
520
+ conflict: true,
521
+ message: `Can't adopt remote version in '${this.stateIndicator}' state`
522
+ });
523
+ }
524
+ }
525
+ if (version) {
526
+ if ((remote.current === version)
527
+ || ((_a = remote.archived) === null || _a === void 0 ? void 0 : _a.includes(version))) {
528
+ this.status.synced = { version, base: remote.diffToBase[version] };
353
529
  }
354
530
  else {
355
- this.status.syncTasks = undefined;
531
+ throw (0, exceptions_1.makeFSSyncException)('', {
532
+ remoteVersion: remote.current,
533
+ versionNotFound: true,
534
+ message: `Remote version ${version} is not in status info`
535
+ });
356
536
  }
357
- await this.triggerSaveProc();
358
537
  }
359
- }
360
- isSyncDone() {
361
- return !this.status.syncTasks;
362
- }
363
- isFileSaved() {
364
- return this.saveProc.isSaved();
365
- }
366
- stat() {
367
- return json_utils_1.copy(this.status.sync);
538
+ else if (remote.current) {
539
+ version = remote.current;
540
+ this.status.synced = { version, base: remote.diffToBase[version] };
541
+ }
542
+ else {
543
+ throw (0, exceptions_1.makeFSSyncException)('', {
544
+ versionMismatch: true,
545
+ message: `Current remote version is not set in status info`
546
+ });
547
+ }
548
+ if (local) {
549
+ this.status.local = undefined;
550
+ }
551
+ this.updateStateIndicator();
552
+ await this.triggerSaveProc();
368
553
  }
369
554
  }
370
555
  exports.ObjStatus = ObjStatus;
371
556
  Object.freeze(ObjStatus.prototype);
372
557
  Object.freeze(ObjStatus);
373
558
  async function readAndCheckStatus(objFolder, objId) {
374
- const status = await obj_info_file_1.readJSONInfoFileIn(objFolder, exports.STATUS_FILE_NAME);
559
+ const status = await (0, obj_info_file_1.readJSONInfoFileIn)(objFolder, exports.STATUS_FILE_NAME);
375
560
  if (!status) {
376
- throw exceptions_1.makeStorageException({
561
+ throw (0, exceptions_1.makeStorageException)({
377
562
  message: `Obj status file is not found in obj folder ${objFolder}`
378
563
  });
379
564
  }
380
565
  // XXX we may do some checks and sanitization here
381
566
  if (objId !== status.objId) {
382
- throw exceptions_1.makeStorageException({ message: `Invalid objId in status file for obj ${objId}, in folder ${objFolder}.\nInvalid content:\n${JSON.stringify(status, null, 2)}` });
567
+ throw (0, exceptions_1.makeStorageException)({
568
+ message: `Invalid objId in status file for obj ${objId}, in folder ${objFolder}.\nInvalid content:\n${JSON.stringify(status, null, 2)}`
569
+ });
383
570
  }
384
571
  return status;
385
572
  }
386
573
  exports.readAndCheckStatus = readAndCheckStatus;
387
- function lastIn(arr) {
388
- return ((arr.length > 0) ? arr[arr.length - 1] : undefined);
574
+ function localVersionFromStatus(tagged) {
575
+ return (tagged ? {
576
+ latest: tagged.current,
577
+ isArchived: tagged.isArchived
578
+ } : undefined);
579
+ }
580
+ function splitVersionsIntoBranches(remote, synced) {
581
+ if (synced) {
582
+ if (isSyncedCurrentWithRemote(synced, remote)) {
583
+ return {
584
+ synced: versionsToBranch(remote)
585
+ };
586
+ }
587
+ else {
588
+ (0, assert_1.assert)(!!synced.version);
589
+ return {
590
+ synced: versionsToBranch(remote, synced.version, false),
591
+ remote: versionsToBranch(remote, synced.version, true)
592
+ };
593
+ }
594
+ }
595
+ else {
596
+ return (isRemoteEmpty(remote) ? {} : {
597
+ remote: versionsToBranch(remote)
598
+ });
599
+ }
600
+ }
601
+ function versionsToBranch({ current, archived, isArchived }, splitVersion, aboveSplit) {
602
+ if (splitVersion) {
603
+ let splitArchived = undefined;
604
+ if (archived) {
605
+ const indAboveSplit = archived.findIndex(v => (v > splitVersion));
606
+ if (aboveSplit) {
607
+ if (indAboveSplit >= 0) {
608
+ splitArchived = archived.slice(indAboveSplit);
609
+ }
610
+ }
611
+ else {
612
+ if (indAboveSplit > 0) {
613
+ splitArchived = archived.slice(0, indAboveSplit);
614
+ }
615
+ else {
616
+ splitArchived = archived.slice();
617
+ }
618
+ }
619
+ }
620
+ return {
621
+ archived: splitArchived,
622
+ latest: (aboveSplit ? current : splitVersion),
623
+ isArchived: isArchived
624
+ };
625
+ }
626
+ else {
627
+ return {
628
+ archived: archived === null || archived === void 0 ? void 0 : archived.slice(),
629
+ latest: current,
630
+ isArchived: isArchived
631
+ };
632
+ }
633
+ }
634
+ function removeArchVersionsNotInList(remote, versionsToKeep) {
635
+ let isAnythingChanged = false;
636
+ if (remote.archived) {
637
+ for (const v of remote.archived) {
638
+ if (!(versionsToKeep === null || versionsToKeep === void 0 ? void 0 : versionsToKeep.includes(v))) {
639
+ (0, obj_info_file_1.rmArchVersionFrom)(remote, v);
640
+ isAnythingChanged = true;
641
+ }
642
+ }
643
+ }
644
+ return isAnythingChanged;
645
+ }
646
+ function addArchVersionsFromList(remote, existingVersions) {
647
+ var _a;
648
+ if (!existingVersions) {
649
+ return false;
650
+ }
651
+ let isAnythingChanged = false;
652
+ for (const v of existingVersions) {
653
+ if (!((_a = remote.archived) === null || _a === void 0 ? void 0 : _a.includes(v))) {
654
+ (0, obj_info_file_1.addArchived)(remote, v);
655
+ }
656
+ }
657
+ return isAnythingChanged;
389
658
  }
390
- function nonGarbageVersionInTask(task) {
391
- if (task.type === 'upload') {
392
- return task.version;
659
+ function skipNotFoundExc(exc) {
660
+ if (!exc.notFound) {
661
+ throw exc;
393
662
  }
394
663
  }
395
664
  Object.freeze(exports);