@blocklet/did-space-js 1.0.15 → 1.0.16
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.
|
@@ -18,6 +18,10 @@ export declare abstract class IncrementalSyncBaseCommand<CommandInput extends In
|
|
|
18
18
|
static readonly MAX_RETRY_COUNT: number;
|
|
19
19
|
static readonly DEFAULT_CONCURRENCY: number;
|
|
20
20
|
static readonly MAX_CONCURRENCY: number;
|
|
21
|
+
static readonly EVENTS: {
|
|
22
|
+
SYNC_BEFORE: string;
|
|
23
|
+
SYNC_AFTER: string;
|
|
24
|
+
};
|
|
21
25
|
private retryCount;
|
|
22
26
|
constructor(input: IncrementalSyncBaseCommandInput, context?: SpaceClientOptions);
|
|
23
27
|
private initialize;
|
|
@@ -35,6 +35,10 @@ class IncrementalSyncBaseCommand extends base_1.BaseCommand {
|
|
|
35
35
|
static MAX_RETRY_COUNT = 10;
|
|
36
36
|
static DEFAULT_CONCURRENCY = 4;
|
|
37
37
|
static MAX_CONCURRENCY = (0, os_1.cpus)().length;
|
|
38
|
+
static EVENTS = {
|
|
39
|
+
SYNC_BEFORE: 'sync.before',
|
|
40
|
+
SYNC_AFTER: 'sync.after',
|
|
41
|
+
};
|
|
38
42
|
retryCount = 0;
|
|
39
43
|
constructor(input, context) {
|
|
40
44
|
// @ts-expect-error
|
|
@@ -92,7 +96,7 @@ class IncrementalSyncBaseCommand extends base_1.BaseCommand {
|
|
|
92
96
|
const remaining = totalCount - errorCount - completedCount;
|
|
93
97
|
const progress = ((completedCount * 100) / totalCount).toFixed(2);
|
|
94
98
|
const duration = (Date.now() - this.startTime) / 1000;
|
|
95
|
-
logger_1.logger.info(`[${direction}] pending: ${this.queue.pending}, completed: ${completedCount}, error: ${errorCount}, remaining: ${remaining}, progress: ${progress}%, total: ${totalCount}, retryCount: ${this.input.retryCount}, duration: ${duration}(s)`);
|
|
99
|
+
logger_1.logger.info(`[${direction}] target: ${this.input.target}, pending: ${this.queue.pending}, completed: ${completedCount}, error: ${errorCount}, remaining: ${remaining}, progress: ${progress}%, total: ${totalCount}, retryCount: ${this.input.retryCount}, duration: ${duration}(s)`);
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
98
102
|
*
|
|
@@ -114,10 +114,10 @@ class IncrementalSyncPushCommand extends sync_base_1.IncrementalSyncBaseCommand
|
|
|
114
114
|
}
|
|
115
115
|
registerEvents() {
|
|
116
116
|
this.removeAllListeners();
|
|
117
|
-
this.on(
|
|
117
|
+
this.on(sync_base_1.IncrementalSyncBaseCommand.EVENTS.SYNC_BEFORE, async (input) => {
|
|
118
118
|
await this.input?.onProgress?.(input);
|
|
119
119
|
});
|
|
120
|
-
this.on(
|
|
120
|
+
this.on(sync_base_1.IncrementalSyncBaseCommand.EVENTS.SYNC_AFTER, async (input) => {
|
|
121
121
|
await this.input?.onAfterUpload?.(input);
|
|
122
122
|
});
|
|
123
123
|
}
|
|
@@ -145,10 +145,10 @@ class IncrementalSyncPushCommand extends sync_base_1.IncrementalSyncBaseCommand
|
|
|
145
145
|
await this.copyObjectToTmpDir(x);
|
|
146
146
|
const sourceKey = x.tempAbsolutePath;
|
|
147
147
|
const targetKey = (0, path_1.join)(this.input.target, x.key);
|
|
148
|
-
this.emit(
|
|
148
|
+
this.emit(sync_base_1.IncrementalSyncBaseCommand.EVENTS.SYNC_BEFORE, {
|
|
149
149
|
completed: completedCount,
|
|
150
150
|
total: totalCount,
|
|
151
|
-
key:
|
|
151
|
+
key: x.key,
|
|
152
152
|
});
|
|
153
153
|
if (x.action === 'PUT' && !(await this.shouldBeBackup(sourceKey))) {
|
|
154
154
|
debug('sync.return', {
|
|
@@ -182,10 +182,10 @@ class IncrementalSyncPushCommand extends sync_base_1.IncrementalSyncBaseCommand
|
|
|
182
182
|
errorCount,
|
|
183
183
|
totalCount,
|
|
184
184
|
});
|
|
185
|
-
this.emit(
|
|
185
|
+
this.emit(sync_base_1.IncrementalSyncBaseCommand.EVENTS.SYNC_AFTER, {
|
|
186
186
|
completed: completedCount,
|
|
187
187
|
total: totalCount,
|
|
188
|
-
key:
|
|
188
|
+
key: x.key,
|
|
189
189
|
});
|
|
190
190
|
// 结束上传
|
|
191
191
|
debug(`[${(0, logger_1.now)()}] [sync:${x.action}.after] ${sourceKey}=>${targetKey} size=${(0, xbytes_1.default)(x.size, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/did-space-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@arcblock/jwt": "^1.19.9",
|
|
34
34
|
"@arcblock/validator": "^1.19.9",
|
|
35
35
|
"@blocklet/env": "^1.16.38",
|
|
36
|
-
"@did-space/core": "^1.0.
|
|
36
|
+
"@did-space/core": "^1.0.16",
|
|
37
37
|
"@ocap/mcrypto": "^1.19.9",
|
|
38
38
|
"@ocap/util": "^1.19.9",
|
|
39
39
|
"@ocap/wallet": "^1.19.9",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dayjs": "^1.11.13",
|
|
44
44
|
"debug": "^4.4.0",
|
|
45
45
|
"filehound": "^1.17.6",
|
|
46
|
-
"form-data": "^4.0.
|
|
46
|
+
"form-data": "^4.0.2",
|
|
47
47
|
"fs-extra": "^11.3.0",
|
|
48
48
|
"got": "^11.8.6",
|
|
49
49
|
"hasha": "^5.2.2",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"ts-jest": "^28.0.8",
|
|
77
77
|
"typescript": "^4.9.5"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "38490648f9fce60497b731dd50399c4f00955ce3"
|
|
80
80
|
}
|