core-3nweb-client-lib 0.43.4 → 0.43.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-defs/files.d.ts +9 -5
- package/build/core/storage/synced/obj-status.d.ts +1 -1
- package/build/core/storage/synced/obj-status.js +2 -2
- package/build/core/storage/synced/storage.js +1 -5
- package/build/core-ipc/file.js +2 -2
- package/build/lib-client/xsp-fs/folder-node.js +5 -10
- package/build/lib-client/xsp-fs/node-in-fs.d.ts +2 -0
- package/build/lib-client/xsp-fs/node-in-fs.js +11 -5
- package/package.json +1 -1
|
@@ -603,16 +603,19 @@ declare namespace web3n.files {
|
|
|
603
603
|
|
|
604
604
|
/**
|
|
605
605
|
* Adopts remote version.
|
|
606
|
-
*
|
|
606
|
+
* In conflicting state remote version must be present in options.
|
|
607
|
+
* @param opts options let one to pass exact remote version.
|
|
607
608
|
*/
|
|
608
609
|
adoptRemote(opts?: OptionsToAdopteRemote): Promise<void>;
|
|
609
610
|
|
|
610
611
|
}
|
|
611
612
|
|
|
612
613
|
interface OptionsToAdopteRemote {
|
|
613
|
-
|
|
614
|
+
/**
|
|
615
|
+
* Identifies remote version that should be adopted.
|
|
616
|
+
* In conflicting state this must be present.
|
|
617
|
+
*/
|
|
614
618
|
remoteVersion?: number;
|
|
615
|
-
download?: boolean;
|
|
616
619
|
}
|
|
617
620
|
|
|
618
621
|
interface WritableFileSyncAPI extends ReadonlyFileSyncAPI {
|
|
@@ -1228,9 +1231,10 @@ declare namespace web3n.files {
|
|
|
1228
1231
|
download(path: string, version: number): Promise<void>;
|
|
1229
1232
|
|
|
1230
1233
|
/**
|
|
1231
|
-
* Adopts remote version of fs object at given path
|
|
1234
|
+
* Adopts remote version of fs object at given path.
|
|
1235
|
+
* In conflicting state remote version must be present in options.
|
|
1232
1236
|
* @param path
|
|
1233
|
-
* @param opts options let one to pass exact remote version
|
|
1237
|
+
* @param opts options let one to pass exact remote version.
|
|
1234
1238
|
*/
|
|
1235
1239
|
adoptRemote(path: string, opts?: OptionsToAdopteRemote): Promise<void>;
|
|
1236
1240
|
|
|
@@ -124,7 +124,7 @@ export declare class ObjStatus implements SyncedObjStatus, UploadStatusRecorder
|
|
|
124
124
|
syncStatus(): SyncStatus;
|
|
125
125
|
neverUploaded(): boolean;
|
|
126
126
|
versionBeforeUnsyncedRemoval(): number | undefined;
|
|
127
|
-
adoptRemoteVersion(version?: number
|
|
127
|
+
adoptRemoteVersion(version?: number): Promise<void>;
|
|
128
128
|
isAmongRemote(version: number): boolean;
|
|
129
129
|
}
|
|
130
130
|
export declare function readAndCheckStatus(objFolder: string, objId: ObjId): Promise<ObjStatusInfo>;
|
|
@@ -510,14 +510,14 @@ class ObjStatus {
|
|
|
510
510
|
return this.status.upload.localVersion;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
async adoptRemoteVersion(version
|
|
513
|
+
async adoptRemoteVersion(version) {
|
|
514
514
|
var _a;
|
|
515
515
|
const { local, remote } = this.status;
|
|
516
516
|
if (this.stateIndicator !== 'behind') {
|
|
517
517
|
if (this.stateIndicator === 'synced') {
|
|
518
518
|
return;
|
|
519
519
|
}
|
|
520
|
-
else if (!
|
|
520
|
+
else if ((this.stateIndicator === 'conflicting') && !version) {
|
|
521
521
|
throw (0, exceptions_1.makeFSSyncException)('', {
|
|
522
522
|
localVersion: local === null || local === void 0 ? void 0 : local.current,
|
|
523
523
|
remoteVersion: remote.current,
|
|
@@ -92,11 +92,7 @@ class SyncedStore {
|
|
|
92
92
|
async adoptRemote(objId, opts) {
|
|
93
93
|
const obj = await this.getObjOrThrow(objId);
|
|
94
94
|
const objStatus = obj.statusObj();
|
|
95
|
-
await objStatus.adoptRemoteVersion(opts === null || opts === void 0 ? void 0 : opts.remoteVersion
|
|
96
|
-
if (opts && opts.download) {
|
|
97
|
-
// XXX this needs implementation
|
|
98
|
-
throw new Error('SyncedStore.adoptRemote() with download option needs implementation, probably using SyncedStore.download().');
|
|
99
|
-
}
|
|
95
|
+
await objStatus.adoptRemoteVersion(opts === null || opts === void 0 ? void 0 : opts.remoteVersion);
|
|
100
96
|
this.files.scheduleGC(obj);
|
|
101
97
|
return objStatus.syncStatus().synced.latest;
|
|
102
98
|
}
|
package/build/core-ipc/file.js
CHANGED
|
@@ -1199,7 +1199,7 @@ function remoteAdoptionOptsToMsg(opts) {
|
|
|
1199
1199
|
return;
|
|
1200
1200
|
}
|
|
1201
1201
|
return {
|
|
1202
|
-
dropLocalVer:
|
|
1202
|
+
// dropLocalVer: toOptVal(opts.dropLocalVer),
|
|
1203
1203
|
remoteVersion: (0, protobuf_msg_1.toOptVal)(opts.remoteVersion)
|
|
1204
1204
|
};
|
|
1205
1205
|
}
|
|
@@ -1208,7 +1208,7 @@ function remoteAdoptionOptsFromMsg(msg) {
|
|
|
1208
1208
|
return;
|
|
1209
1209
|
}
|
|
1210
1210
|
return {
|
|
1211
|
-
dropLocalVer:
|
|
1211
|
+
// dropLocalVer: valOfOpt(msg.dropLocalVer),
|
|
1212
1212
|
remoteVersion: (0, protobuf_msg_1.valOfOptInt)(msg.remoteVersion)
|
|
1213
1213
|
};
|
|
1214
1214
|
}
|
|
@@ -383,10 +383,10 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
383
383
|
const attrs = this.attrs.copy();
|
|
384
384
|
// do action within transition state
|
|
385
385
|
const changeEvents = await change(state, version);
|
|
386
|
-
// save
|
|
386
|
+
// save new state
|
|
387
387
|
const encSub = await this.crypto.write(state, version, attrs, this.xattrs);
|
|
388
388
|
await this.storage.saveObj(this.objId, version, encSub);
|
|
389
|
-
//
|
|
389
|
+
// apply new state to in-memory object
|
|
390
390
|
this.currentState = state;
|
|
391
391
|
this.setCurrentVersion(version);
|
|
392
392
|
this.attrs = attrs;
|
|
@@ -681,7 +681,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
681
681
|
}
|
|
682
682
|
async removeFolderObj(src, passIdsForRmUpload = false) {
|
|
683
683
|
const childrenNodes = await this.doChange(true, async () => {
|
|
684
|
-
if (this.
|
|
684
|
+
if (this.isMarkedRemoved) {
|
|
685
685
|
return;
|
|
686
686
|
}
|
|
687
687
|
const childrenNodes = await this.getAllNodes();
|
|
@@ -692,12 +692,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
694
694
|
if (this.isInSyncedStorage) {
|
|
695
|
-
|
|
696
|
-
return this.removeChildrenObjsInSyncedStorage(childrenNodes, src, true);
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
this.removeChildrenObjsInSyncedStorage(childrenNodes, src, false);
|
|
700
|
-
}
|
|
695
|
+
return await this.removeChildrenObjsInSyncedStorage(childrenNodes, src, passIdsForRmUpload);
|
|
701
696
|
}
|
|
702
697
|
else {
|
|
703
698
|
this.callRemoveObjOnAll(src, childrenNodes);
|
|
@@ -709,7 +704,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
709
704
|
}
|
|
710
705
|
}
|
|
711
706
|
async removeChildrenObjsInSyncedStorage(childrenNodes, src, passIdsForRmUpload) {
|
|
712
|
-
if (this.
|
|
707
|
+
if (this.isMarkedRemoved) {
|
|
713
708
|
return;
|
|
714
709
|
}
|
|
715
710
|
let uploadRmsHere;
|
|
@@ -23,6 +23,8 @@ export declare abstract class NodeInFS<P extends NodePersistance> implements Nod
|
|
|
23
23
|
private writeProc;
|
|
24
24
|
get version(): number;
|
|
25
25
|
protected setCurrentVersion(newVersion: number): void;
|
|
26
|
+
private markRemoved;
|
|
27
|
+
protected get isMarkedRemoved(): boolean;
|
|
26
28
|
readonly isInSyncedStorage: boolean;
|
|
27
29
|
protected constructor(storage: Storage, type: NodeType, name: string, objId: string, currentVersion: number, parentId: string | undefined);
|
|
28
30
|
protected getObjSrcOfVersion(flags: VersionedReadFlags | undefined): Promise<ObjSource>;
|
|
@@ -37,11 +37,17 @@ class NodeInFS {
|
|
|
37
37
|
return this.currentVersion;
|
|
38
38
|
}
|
|
39
39
|
setCurrentVersion(newVersion) {
|
|
40
|
-
if (!Number.isInteger(newVersion)) {
|
|
41
|
-
throw new TypeError(`Version parameter must be
|
|
40
|
+
if (!Number.isInteger(newVersion) || (newVersion < 0)) {
|
|
41
|
+
throw new TypeError(`Version parameter must be a non-negative integer, but ${newVersion} is given`);
|
|
42
42
|
}
|
|
43
43
|
this.currentVersion = newVersion;
|
|
44
44
|
}
|
|
45
|
+
markRemoved() {
|
|
46
|
+
this.currentVersion = -1;
|
|
47
|
+
}
|
|
48
|
+
get isMarkedRemoved() {
|
|
49
|
+
return (this.currentVersion < 0);
|
|
50
|
+
}
|
|
45
51
|
constructor(storage, type, name, objId, currentVersion, parentId) {
|
|
46
52
|
this.storage = storage;
|
|
47
53
|
this.type = type;
|
|
@@ -184,12 +190,12 @@ class NodeInFS {
|
|
|
184
190
|
return this.doChange(true, () => this.removeThisFromStorageNodes(src));
|
|
185
191
|
}
|
|
186
192
|
async removeThisFromStorageNodes(src) {
|
|
187
|
-
if (this.
|
|
193
|
+
if (this.isMarkedRemoved) {
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
190
196
|
await this.storage.removeObj(this.objId);
|
|
191
197
|
this.storage.nodes.delete(this);
|
|
192
|
-
this.
|
|
198
|
+
this.markRemoved();
|
|
193
199
|
const event = {
|
|
194
200
|
type: 'removed',
|
|
195
201
|
path: this.name,
|
|
@@ -217,7 +223,7 @@ class NodeInFS {
|
|
|
217
223
|
throw (0, runtime_1.makeRuntimeException)('file', { path: this.name, fsEtityType: this.type }, { concurrentUpdate: true });
|
|
218
224
|
}
|
|
219
225
|
const res = await this.writeProc.startOrChain(async () => {
|
|
220
|
-
if (this.
|
|
226
|
+
if (this.isMarkedRemoved) {
|
|
221
227
|
throw (0, runtime_1.makeRuntimeException)('file', {
|
|
222
228
|
path: this.name, fsEtityType: this.type,
|
|
223
229
|
message: `NodeInFS is marked removed`
|