@milaboratories/pl-drivers 1.5.6 → 1.5.7
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/dist/drivers/upload_task.d.ts +3 -0
- package/dist/drivers/upload_task.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/drivers/upload_task.ts +30 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-drivers",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Drivers and a low-level clients for log streaming, downloading and uploading files from and to pl",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
"src/**/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@grpc/grpc-js": "^1.12.
|
|
20
|
+
"@grpc/grpc-js": "^1.12.5",
|
|
21
21
|
"@protobuf-ts/grpc-transport": "^2.9.4",
|
|
22
22
|
"@protobuf-ts/runtime": "^2.9.4",
|
|
23
23
|
"@protobuf-ts/runtime-rpc": "^2.9.4",
|
|
24
24
|
"@protobuf-ts/plugin": "^2.9.4",
|
|
25
25
|
"denque": "^2.1.0",
|
|
26
26
|
"tar-fs": "^3.0.6",
|
|
27
|
-
"undici": "^7.
|
|
27
|
+
"undici": "^7.2.0",
|
|
28
28
|
"zod": "~3.23.8",
|
|
29
|
-
"@milaboratories/ts-helpers": "^1.1.3",
|
|
30
29
|
"@milaboratories/computable": "^2.3.4",
|
|
30
|
+
"@milaboratories/ts-helpers": "^1.1.3",
|
|
31
31
|
"@milaboratories/pl-client": "^2.7.1",
|
|
32
|
-
"@milaboratories/pl-
|
|
33
|
-
"@milaboratories/pl-
|
|
32
|
+
"@milaboratories/pl-model-common": "^1.10.2",
|
|
33
|
+
"@milaboratories/pl-tree": "^1.4.20"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"typescript": "~5.5.4",
|
|
@@ -21,6 +21,10 @@ export class UploadTask {
|
|
|
21
21
|
/** If failed, then getting a progress is terminally failed. */
|
|
22
22
|
public failed?: boolean;
|
|
23
23
|
|
|
24
|
+
/** True if the blob was existed.
|
|
25
|
+
* At this case, the task will show progress == 1.0. */
|
|
26
|
+
private alreadyExisted = false;
|
|
27
|
+
|
|
24
28
|
constructor(
|
|
25
29
|
private readonly logger: MiLogger,
|
|
26
30
|
private readonly clientBlob: ClientUpload,
|
|
@@ -107,10 +111,13 @@ export class UploadTask {
|
|
|
107
111
|
const status = await this.clientProgress.getStatus(this.res);
|
|
108
112
|
|
|
109
113
|
const oldStatus = this.progress.status;
|
|
110
|
-
this.
|
|
114
|
+
const newStatus = doneProgressIfExisted(this.alreadyExisted, protoToStatus(status));
|
|
115
|
+
this.progress.status = newStatus;
|
|
111
116
|
this.setDone(status.done);
|
|
112
117
|
|
|
113
|
-
if (status.done || status.progress != oldStatus?.progress)
|
|
118
|
+
if (status.done || this.progress.status.progress != oldStatus?.progress) {
|
|
119
|
+
this.change.markChanged();
|
|
120
|
+
}
|
|
114
121
|
} catch (e: any) {
|
|
115
122
|
this.setRetriableError(e);
|
|
116
123
|
|
|
@@ -147,7 +154,10 @@ export class UploadTask {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
public setDoneIfOutputSet(res: ImportResourceSnapshot) {
|
|
150
|
-
if (isImportResourceOutputSet(res))
|
|
157
|
+
if (isImportResourceOutputSet(res)) {
|
|
158
|
+
this.setDone(true);
|
|
159
|
+
this.alreadyExisted = true;
|
|
160
|
+
}
|
|
151
161
|
}
|
|
152
162
|
|
|
153
163
|
private setDone(done: boolean) {
|
|
@@ -239,6 +249,23 @@ function protoToStatus(proto: ProgressStatus): sdk.ImportStatus {
|
|
|
239
249
|
};
|
|
240
250
|
}
|
|
241
251
|
|
|
252
|
+
/** Special hack: if we didn't even start to upload the blob
|
|
253
|
+
* to backend because the result was already there,
|
|
254
|
+
* the backend does show us a status that nothing were uploaded,
|
|
255
|
+
* but we need to show the client that everything is OK.
|
|
256
|
+
* Thus, here we set progress to be 1.0 and all bytes are become processed. */
|
|
257
|
+
function doneProgressIfExisted(alreadyExisted: boolean, status: sdk.ImportStatus) {
|
|
258
|
+
if (alreadyExisted && status.bytesTotal != 0 && status.bytesProcessed == 0) {
|
|
259
|
+
return {
|
|
260
|
+
progress: 1.0,
|
|
261
|
+
bytesProcessed: Number(status.bytesTotal),
|
|
262
|
+
bytesTotal: Number(status.bytesTotal)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return status;
|
|
267
|
+
}
|
|
268
|
+
|
|
242
269
|
export function isResourceWasDeletedError(e: any) {
|
|
243
270
|
return (
|
|
244
271
|
e.name == 'RpcError' &&
|