@milaboratories/pl-drivers 1.6.12 → 1.7.0
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/download_blob_url/driver.d.ts.map +1 -1
- package/dist/drivers/download_blob_url/url.d.ts +0 -5
- package/dist/drivers/download_blob_url/url.d.ts.map +1 -1
- package/dist/drivers/{download_url.d.ts → download_url/driver.d.ts} +25 -41
- package/dist/drivers/download_url/driver.d.ts.map +1 -0
- package/dist/drivers/download_url/task.d.ts +40 -0
- package/dist/drivers/download_url/task.d.ts.map +1 -0
- package/dist/drivers/urls/url.d.ts +13 -0
- package/dist/drivers/urls/url.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +506 -484
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/drivers/download_blob_url/driver.ts +2 -2
- package/src/drivers/download_blob_url/task.ts +1 -1
- package/src/drivers/download_blob_url/url.ts +0 -43
- package/src/drivers/{download_url.test.ts → download_url/driver.test.ts} +32 -25
- package/src/drivers/{download_url.ts → download_url/driver.ts} +55 -156
- package/src/drivers/download_url/task.ts +151 -0
- package/src/drivers/{download_blob_url → urls}/url.test.ts +26 -3
- package/src/drivers/urls/url.ts +68 -0
- package/src/index.ts +1 -1
- package/dist/drivers/download_url.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (s, e, t) =>
|
|
4
|
-
import { addRTypeToMetadata as R, stringifyWithResourceId as m, bigintToResourceId as Te, resourceIdToString as
|
|
1
|
+
var kt = Object.defineProperty;
|
|
2
|
+
var Tt = (s, e, t) => e in s ? kt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var h = (s, e, t) => Tt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { addRTypeToMetadata as R, stringifyWithResourceId as m, bigintToResourceId as Te, resourceIdToString as U, isNotNullResourceId as Lt } from "@milaboratories/pl-client";
|
|
5
5
|
import * as w from "node:fs/promises";
|
|
6
6
|
import { request as We } from "undici";
|
|
7
7
|
import { ServiceType as O, stackIntercept as P } from "@protobuf-ts/runtime-rpc";
|
|
8
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as p, PbLong as $, typeofJsonValue as xe, assertNever as
|
|
9
|
-
import { notEmpty as J, CallersCounter as v, ensureDirExists as F, fileExists as z, createPathAtomically as Z, mapGet as ge, mapEntries as Ae, spawnAsync as Pt, TaskProcessor as Q, asyncPool as Le, assertNever as
|
|
10
|
-
import * as
|
|
8
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as p, PbLong as $, typeofJsonValue as xe, assertNever as Ut } from "@protobuf-ts/runtime";
|
|
9
|
+
import { notEmpty as J, CallersCounter as v, ensureDirExists as F, fileExists as z, createPathAtomically as Z, mapGet as ge, mapEntries as Ae, spawnAsync as Pt, TaskProcessor as Q, asyncPool as Le, assertNever as Rt } from "@milaboratories/ts-helpers";
|
|
10
|
+
import * as Ue from "node:fs";
|
|
11
11
|
import fe, { promises as we } from "node:fs";
|
|
12
12
|
import * as k from "node:path";
|
|
13
|
-
import
|
|
14
|
-
import { Readable as
|
|
15
|
-
import { text as
|
|
13
|
+
import L from "node:path";
|
|
14
|
+
import { Readable as Pe, Writable as I, Transform as Me } from "node:stream";
|
|
15
|
+
import { text as Nt, buffer as He } from "node:stream/consumers";
|
|
16
16
|
import { ChangeSource as B, Computable as y, PollingComputableHooks as je } from "@milaboratories/computable";
|
|
17
|
-
import { RangeBytes as
|
|
17
|
+
import { RangeBytes as $t, validateRangeBytes as De, isFolderURL as St, isBlockUIURL as It, isImportFileHandleIndex as Dt } from "@milaboratories/pl-model-common";
|
|
18
18
|
import { rsSchema as K, treeEntryToResourceInfo as S, isPlTreeEntry as W, makeResourceSnapshot as G, isPlTreeEntryAccessor as Ge } from "@milaboratories/pl-tree";
|
|
19
|
-
import
|
|
20
|
-
import { randomUUID as N, createHash as
|
|
19
|
+
import vt from "denque";
|
|
20
|
+
import { randomUUID as N, createHash as Bt } from "node:crypto";
|
|
21
21
|
import * as ve from "node:os";
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
22
|
+
import Ct from "node:os";
|
|
23
|
+
import * as _t from "node:readline/promises";
|
|
24
24
|
import { z as T } from "zod";
|
|
25
|
-
import { functions as
|
|
25
|
+
import { functions as Et } from "@milaboratories/helpers";
|
|
26
26
|
import * as Ve from "node:zlib";
|
|
27
27
|
import * as me from "tar-fs";
|
|
28
|
-
import
|
|
28
|
+
import Ft from "decompress";
|
|
29
29
|
import { scheduler as qe } from "node:timers/promises";
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import { exec as
|
|
33
|
-
class
|
|
30
|
+
import Ot from "node:assert";
|
|
31
|
+
import zt from "node:util";
|
|
32
|
+
import { exec as Wt } from "node:child_process";
|
|
33
|
+
class xt extends g {
|
|
34
34
|
constructor() {
|
|
35
35
|
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
36
36
|
}
|
|
@@ -58,8 +58,8 @@ class Ot extends g {
|
|
|
58
58
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
new
|
|
62
|
-
class
|
|
61
|
+
new xt();
|
|
62
|
+
class At extends g {
|
|
63
63
|
constructor() {
|
|
64
64
|
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
65
65
|
}
|
|
@@ -87,8 +87,8 @@ class zt extends g {
|
|
|
87
87
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
new
|
|
91
|
-
class
|
|
90
|
+
new At();
|
|
91
|
+
class Mt extends g {
|
|
92
92
|
constructor() {
|
|
93
93
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
94
94
|
{
|
|
@@ -130,8 +130,8 @@ class Wt extends g {
|
|
|
130
130
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
class
|
|
133
|
+
const Ht = new Mt();
|
|
134
|
+
class jt extends g {
|
|
135
135
|
constructor() {
|
|
136
136
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
137
137
|
{
|
|
@@ -195,8 +195,8 @@ class At extends g {
|
|
|
195
195
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const
|
|
199
|
-
class
|
|
198
|
+
const Gt = new jt();
|
|
199
|
+
class Vt extends g {
|
|
200
200
|
constructor() {
|
|
201
201
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
202
202
|
}
|
|
@@ -224,8 +224,8 @@ class Ht extends g {
|
|
|
224
224
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
new
|
|
228
|
-
class
|
|
227
|
+
new Vt();
|
|
228
|
+
class qt extends g {
|
|
229
229
|
constructor() {
|
|
230
230
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
231
231
|
{
|
|
@@ -279,8 +279,8 @@ class jt extends g {
|
|
|
279
279
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
class
|
|
282
|
+
const Jt = new qt();
|
|
283
|
+
class Zt extends g {
|
|
284
284
|
constructor() {
|
|
285
285
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response", []);
|
|
286
286
|
}
|
|
@@ -308,8 +308,8 @@ class Vt extends g {
|
|
|
308
308
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
class
|
|
311
|
+
const Qt = new Zt();
|
|
312
|
+
class Kt extends g {
|
|
313
313
|
constructor() {
|
|
314
314
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
315
315
|
}
|
|
@@ -337,8 +337,8 @@ class Jt extends g {
|
|
|
337
337
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
new
|
|
341
|
-
class
|
|
340
|
+
new Kt();
|
|
341
|
+
class Xt extends g {
|
|
342
342
|
constructor() {
|
|
343
343
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
344
344
|
{
|
|
@@ -415,8 +415,8 @@ class Zt extends g {
|
|
|
415
415
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
const
|
|
419
|
-
class
|
|
418
|
+
const Yt = new Xt();
|
|
419
|
+
class er extends g {
|
|
420
420
|
constructor() {
|
|
421
421
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
422
422
|
{
|
|
@@ -470,8 +470,8 @@ class Kt extends g {
|
|
|
470
470
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
const te = new
|
|
474
|
-
class
|
|
473
|
+
const te = new er();
|
|
474
|
+
class tr extends g {
|
|
475
475
|
constructor() {
|
|
476
476
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
477
477
|
{
|
|
@@ -555,8 +555,8 @@ class Xt extends g {
|
|
|
555
555
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
const
|
|
559
|
-
class
|
|
558
|
+
const rr = new tr();
|
|
559
|
+
class or extends g {
|
|
560
560
|
constructor() {
|
|
561
561
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
562
562
|
}
|
|
@@ -584,8 +584,8 @@ class er extends g {
|
|
|
584
584
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
new
|
|
588
|
-
class
|
|
587
|
+
new or();
|
|
588
|
+
class nr extends g {
|
|
589
589
|
constructor() {
|
|
590
590
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
591
591
|
{
|
|
@@ -627,8 +627,8 @@ class tr extends g {
|
|
|
627
627
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
const
|
|
631
|
-
class
|
|
630
|
+
const sr = new nr();
|
|
631
|
+
class ir extends g {
|
|
632
632
|
constructor() {
|
|
633
633
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
634
634
|
}
|
|
@@ -656,13 +656,13 @@ class or extends g {
|
|
|
656
656
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
const
|
|
660
|
-
{ name: "Init", options: {}, I:
|
|
661
|
-
{ name: "GetPartURL", options: {}, I:
|
|
662
|
-
{ name: "UpdateProgress", options: {}, I:
|
|
663
|
-
{ name: "Finalize", options: {}, I:
|
|
659
|
+
const ar = new ir(), re = new O("MiLaboratories.Controller.Shared.Upload", [
|
|
660
|
+
{ name: "Init", options: {}, I: Ht, O: Gt },
|
|
661
|
+
{ name: "GetPartURL", options: {}, I: Yt, O: rr },
|
|
662
|
+
{ name: "UpdateProgress", options: {}, I: Jt, O: Qt },
|
|
663
|
+
{ name: "Finalize", options: {}, I: sr, O: ar }
|
|
664
664
|
]);
|
|
665
|
-
class
|
|
665
|
+
class lr {
|
|
666
666
|
constructor(e) {
|
|
667
667
|
h(this, "typeName", re.typeName);
|
|
668
668
|
h(this, "methods", re.methods);
|
|
@@ -745,10 +745,10 @@ class Xe extends Error {
|
|
|
745
745
|
h(this, "name", "NoFileForUploading");
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
|
-
class
|
|
748
|
+
class cr {
|
|
749
749
|
constructor(e, t, r, o) {
|
|
750
750
|
h(this, "grpcClient");
|
|
751
|
-
this.httpClient = t, this.logger = o, this.grpcClient = e.createGrpcClientProvider((n) => new
|
|
751
|
+
this.httpClient = t, this.logger = o, this.grpcClient = e.createGrpcClientProvider((n) => new lr(n));
|
|
752
752
|
}
|
|
753
753
|
close() {
|
|
754
754
|
}
|
|
@@ -766,8 +766,8 @@ class ir {
|
|
|
766
766
|
0n,
|
|
767
767
|
// we update progress as a separate call later.
|
|
768
768
|
l
|
|
769
|
-
), c = await
|
|
770
|
-
await
|
|
769
|
+
), c = await hr(r, i.chunkStart, i.chunkEnd);
|
|
770
|
+
await ur(r, o);
|
|
771
771
|
try {
|
|
772
772
|
const {
|
|
773
773
|
body: a,
|
|
@@ -784,8 +784,8 @@ class ir {
|
|
|
784
784
|
bodyTimeout: 6e4,
|
|
785
785
|
headers: Je(i.headers),
|
|
786
786
|
method: i.method.toUpperCase()
|
|
787
|
-
}),
|
|
788
|
-
|
|
787
|
+
}), bt = await a.text();
|
|
788
|
+
pr(d, bt, ee, i);
|
|
789
789
|
} catch (a) {
|
|
790
790
|
throw a instanceof Ke ? a : new Error(`partUpload: error ${JSON.stringify(a)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
|
|
791
791
|
}
|
|
@@ -824,11 +824,11 @@ class ir {
|
|
|
824
824
|
return await this.grpcClient.get().finalize({ resourceId: e }, R(t, r)).response;
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
async function
|
|
827
|
+
async function hr(s, e, t) {
|
|
828
828
|
let r;
|
|
829
829
|
try {
|
|
830
830
|
r = await w.open(s);
|
|
831
|
-
const o = Number(t - e), n = Number(e), l = Buffer.alloc(o), i = await
|
|
831
|
+
const o = Number(t - e), n = Number(e), l = Buffer.alloc(o), i = await dr(r, l, o, n);
|
|
832
832
|
return l.subarray(0, i);
|
|
833
833
|
} catch (o) {
|
|
834
834
|
throw o && typeof o == "object" && "code" in o && o.code == "ENOENT" ? new Xe(`there is no file ${s} for uploading`) : o;
|
|
@@ -836,7 +836,7 @@ async function ar(s, e, t) {
|
|
|
836
836
|
await (r == null ? void 0 : r.close());
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
async function
|
|
839
|
+
async function dr(s, e, t, r) {
|
|
840
840
|
let o = 0;
|
|
841
841
|
for (; o < t; ) {
|
|
842
842
|
const { bytesRead: n } = await s.read(
|
|
@@ -851,18 +851,18 @@ async function lr(s, e, t, r) {
|
|
|
851
851
|
}
|
|
852
852
|
return o;
|
|
853
853
|
}
|
|
854
|
-
async function
|
|
854
|
+
async function ur(s, e) {
|
|
855
855
|
const t = BigInt(Math.floor((await w.stat(s)).mtimeMs / 1e3));
|
|
856
856
|
if (t > e)
|
|
857
857
|
throw new Ze(`file was modified, expected mtime: ${e}, got: ${t}.`);
|
|
858
858
|
}
|
|
859
|
-
function
|
|
859
|
+
function pr(s, e, t, r) {
|
|
860
860
|
if (s != 200)
|
|
861
861
|
throw new Ke(
|
|
862
862
|
`response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${r.uploadUrl}`
|
|
863
863
|
);
|
|
864
864
|
}
|
|
865
|
-
class
|
|
865
|
+
class gr extends g {
|
|
866
866
|
constructor() {
|
|
867
867
|
super("google.protobuf.Duration", [
|
|
868
868
|
{
|
|
@@ -948,8 +948,8 @@ class dr extends g {
|
|
|
948
948
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
|
-
const j = new
|
|
952
|
-
class
|
|
951
|
+
const j = new gr();
|
|
952
|
+
class fr extends g {
|
|
953
953
|
constructor() {
|
|
954
954
|
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
955
955
|
}
|
|
@@ -977,8 +977,8 @@ class ur extends g {
|
|
|
977
977
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
new
|
|
981
|
-
class
|
|
980
|
+
new fr();
|
|
981
|
+
class wr extends g {
|
|
982
982
|
constructor() {
|
|
983
983
|
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
984
984
|
{
|
|
@@ -1065,8 +1065,8 @@ class pr extends g {
|
|
|
1065
1065
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
const
|
|
1069
|
-
class
|
|
1068
|
+
const D = new wr();
|
|
1069
|
+
class mr extends g {
|
|
1070
1070
|
constructor() {
|
|
1071
1071
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1072
1072
|
}
|
|
@@ -1094,8 +1094,8 @@ class gr extends g {
|
|
|
1094
1094
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
|
-
new
|
|
1098
|
-
class
|
|
1097
|
+
new mr();
|
|
1098
|
+
class yr extends g {
|
|
1099
1099
|
constructor() {
|
|
1100
1100
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1101
1101
|
{
|
|
@@ -1137,11 +1137,11 @@ class fr extends g {
|
|
|
1137
1137
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
|
-
const
|
|
1141
|
-
class
|
|
1140
|
+
const br = new yr();
|
|
1141
|
+
class kr extends g {
|
|
1142
1142
|
constructor() {
|
|
1143
1143
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1144
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1144
|
+
{ no: 1, name: "report", kind: "message", T: () => D }
|
|
1145
1145
|
]);
|
|
1146
1146
|
}
|
|
1147
1147
|
create(e) {
|
|
@@ -1155,7 +1155,7 @@ class mr extends g {
|
|
|
1155
1155
|
switch (i) {
|
|
1156
1156
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1157
1157
|
1:
|
|
1158
|
-
n.report =
|
|
1158
|
+
n.report = D.internalBinaryRead(e, e.uint32(), r, n.report);
|
|
1159
1159
|
break;
|
|
1160
1160
|
default:
|
|
1161
1161
|
let a = r.readUnknownField;
|
|
@@ -1168,13 +1168,13 @@ class mr extends g {
|
|
|
1168
1168
|
return n;
|
|
1169
1169
|
}
|
|
1170
1170
|
internalBinaryWrite(e, t, r) {
|
|
1171
|
-
e.report &&
|
|
1171
|
+
e.report && D.internalBinaryWrite(e.report, t.tag(1, p.LengthDelimited).fork(), r).join();
|
|
1172
1172
|
let o = r.writeUnknownFields;
|
|
1173
1173
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
1176
|
-
const
|
|
1177
|
-
class
|
|
1176
|
+
const Tr = new kr();
|
|
1177
|
+
class Lr extends g {
|
|
1178
1178
|
constructor() {
|
|
1179
1179
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1180
1180
|
}
|
|
@@ -1202,8 +1202,8 @@ class br extends g {
|
|
|
1202
1202
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1203
1203
|
}
|
|
1204
1204
|
}
|
|
1205
|
-
new
|
|
1206
|
-
class
|
|
1205
|
+
new Lr();
|
|
1206
|
+
class Ur extends g {
|
|
1207
1207
|
constructor() {
|
|
1208
1208
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request", [
|
|
1209
1209
|
{
|
|
@@ -1250,11 +1250,11 @@ class kr extends g {
|
|
|
1250
1250
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1251
1251
|
}
|
|
1252
1252
|
}
|
|
1253
|
-
const
|
|
1254
|
-
class
|
|
1253
|
+
const Pr = new Ur();
|
|
1254
|
+
class Rr extends g {
|
|
1255
1255
|
constructor() {
|
|
1256
1256
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response", [
|
|
1257
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1257
|
+
{ no: 1, name: "report", kind: "message", T: () => D }
|
|
1258
1258
|
]);
|
|
1259
1259
|
}
|
|
1260
1260
|
create(e) {
|
|
@@ -1268,7 +1268,7 @@ class Lr extends g {
|
|
|
1268
1268
|
switch (i) {
|
|
1269
1269
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1270
1270
|
1:
|
|
1271
|
-
n.report =
|
|
1271
|
+
n.report = D.internalBinaryRead(e, e.uint32(), r, n.report);
|
|
1272
1272
|
break;
|
|
1273
1273
|
default:
|
|
1274
1274
|
let a = r.readUnknownField;
|
|
@@ -1281,16 +1281,16 @@ class Lr extends g {
|
|
|
1281
1281
|
return n;
|
|
1282
1282
|
}
|
|
1283
1283
|
internalBinaryWrite(e, t, r) {
|
|
1284
|
-
e.report &&
|
|
1284
|
+
e.report && D.internalBinaryWrite(e.report, t.tag(1, p.LengthDelimited).fork(), r).join();
|
|
1285
1285
|
let o = r.writeUnknownFields;
|
|
1286
1286
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1287
1287
|
}
|
|
1288
1288
|
}
|
|
1289
|
-
const
|
|
1290
|
-
{ name: "GetStatus", options: { "google.api.http": { get: "/resources/{resource_id}/get-progress" } }, I:
|
|
1291
|
-
{ name: "RealtimeStatus", serverStreaming: !0, options: {}, I:
|
|
1289
|
+
const Nr = new Rr(), oe = new O("MiLaboratories.Controller.Shared.Progress", [
|
|
1290
|
+
{ name: "GetStatus", options: { "google.api.http": { get: "/resources/{resource_id}/get-progress" } }, I: br, O: Tr },
|
|
1291
|
+
{ name: "RealtimeStatus", serverStreaming: !0, options: {}, I: Pr, O: Nr }
|
|
1292
1292
|
]);
|
|
1293
|
-
class
|
|
1293
|
+
class $r {
|
|
1294
1294
|
constructor(e) {
|
|
1295
1295
|
h(this, "typeName", oe.typeName);
|
|
1296
1296
|
h(this, "methods", oe.methods);
|
|
@@ -1312,10 +1312,10 @@ class Ur {
|
|
|
1312
1312
|
return P("serverStreaming", this._transport, r, o, e);
|
|
1313
1313
|
}
|
|
1314
1314
|
}
|
|
1315
|
-
class
|
|
1315
|
+
class Sr {
|
|
1316
1316
|
constructor(e, t, r, o) {
|
|
1317
1317
|
h(this, "grpcClient");
|
|
1318
|
-
this.client = r, this.logger = o, this.grpcClient = e.createGrpcClientProvider((n) => new
|
|
1318
|
+
this.client = r, this.logger = o, this.grpcClient = e.createGrpcClientProvider((n) => new $r(n));
|
|
1319
1319
|
}
|
|
1320
1320
|
close() {
|
|
1321
1321
|
}
|
|
@@ -1369,26 +1369,26 @@ class Ye {
|
|
|
1369
1369
|
dispatcher: this.httpClient,
|
|
1370
1370
|
headers: t,
|
|
1371
1371
|
signal: r
|
|
1372
|
-
}), i =
|
|
1373
|
-
return await
|
|
1372
|
+
}), i = Pe.toWeb(n);
|
|
1373
|
+
return await Ir(o, i, e), {
|
|
1374
1374
|
content: i,
|
|
1375
1375
|
size: Number(l["content-length"])
|
|
1376
1376
|
};
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
|
-
async function
|
|
1379
|
+
async function Ir(s, e, t) {
|
|
1380
1380
|
if (s != 200 && s != 206) {
|
|
1381
|
-
const r = (await
|
|
1381
|
+
const r = (await Nt(e)).substring(0, 1e3);
|
|
1382
1382
|
throw 400 <= s && s < 500 ? new X(
|
|
1383
1383
|
`Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${r}`
|
|
1384
1384
|
) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
1387
|
function E(s) {
|
|
1388
|
-
if (!
|
|
1388
|
+
if (!L.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1389
1389
|
return s;
|
|
1390
1390
|
}
|
|
1391
|
-
class
|
|
1391
|
+
class Dr extends g {
|
|
1392
1392
|
constructor() {
|
|
1393
1393
|
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1394
1394
|
}
|
|
@@ -1416,8 +1416,8 @@ class $r extends g {
|
|
|
1416
1416
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1417
1417
|
}
|
|
1418
1418
|
}
|
|
1419
|
-
new
|
|
1420
|
-
class
|
|
1419
|
+
new Dr();
|
|
1420
|
+
class vr extends g {
|
|
1421
1421
|
constructor() {
|
|
1422
1422
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1423
1423
|
}
|
|
@@ -1445,8 +1445,8 @@ class Sr extends g {
|
|
|
1445
1445
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
1448
|
-
new
|
|
1449
|
-
class
|
|
1448
|
+
new vr();
|
|
1449
|
+
class Br extends g {
|
|
1450
1450
|
constructor() {
|
|
1451
1451
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request", [
|
|
1452
1452
|
{
|
|
@@ -1499,8 +1499,8 @@ class Dr extends g {
|
|
|
1499
1499
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
1502
|
-
const
|
|
1503
|
-
class
|
|
1502
|
+
const Cr = new Br();
|
|
1503
|
+
class _r extends g {
|
|
1504
1504
|
constructor() {
|
|
1505
1505
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader", [
|
|
1506
1506
|
{
|
|
@@ -1554,8 +1554,8 @@ class vr extends g {
|
|
|
1554
1554
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1555
1555
|
}
|
|
1556
1556
|
}
|
|
1557
|
-
const ne = new
|
|
1558
|
-
class
|
|
1557
|
+
const ne = new _r();
|
|
1558
|
+
class Er extends g {
|
|
1559
1559
|
constructor() {
|
|
1560
1560
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response", [
|
|
1561
1561
|
{
|
|
@@ -1603,10 +1603,10 @@ class Br extends g {
|
|
|
1603
1603
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1604
1604
|
}
|
|
1605
1605
|
}
|
|
1606
|
-
const
|
|
1607
|
-
{ name: "GetDownloadURL", options: { "google.api.http": { get: "/resources/{resource_id}/get-download-url" } }, I:
|
|
1606
|
+
const Fr = new Er(), se = new O("MiLaboratories.Controller.Shared.Download", [
|
|
1607
|
+
{ name: "GetDownloadURL", options: { "google.api.http": { get: "/resources/{resource_id}/get-download-url" } }, I: Cr, O: Fr }
|
|
1608
1608
|
]);
|
|
1609
|
-
class
|
|
1609
|
+
class Or {
|
|
1610
1610
|
constructor(e) {
|
|
1611
1611
|
h(this, "typeName", se.typeName);
|
|
1612
1612
|
h(this, "methods", se.methods);
|
|
@@ -1621,13 +1621,13 @@ class _r {
|
|
|
1621
1621
|
return P("unary", this._transport, r, o, e);
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
|
-
class
|
|
1624
|
+
class zr {
|
|
1625
1625
|
constructor(e, t, r, o) {
|
|
1626
1626
|
h(this, "grpcClient");
|
|
1627
1627
|
h(this, "remoteFileDownloader");
|
|
1628
1628
|
/** Helps to find a storage root directory by a storage id from URL scheme. */
|
|
1629
1629
|
h(this, "localStorageIdsToRoot");
|
|
1630
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((n) => new
|
|
1630
|
+
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((n) => new Or(n)), this.remoteFileDownloader = new Ye(t), this.localStorageIdsToRoot = Hr(o);
|
|
1631
1631
|
}
|
|
1632
1632
|
close() {
|
|
1633
1633
|
}
|
|
@@ -1638,12 +1638,12 @@ class Er {
|
|
|
1638
1638
|
*/
|
|
1639
1639
|
async downloadBlob(e, t, r, o, n) {
|
|
1640
1640
|
const { downloadUrl: l, headers: i } = await this.grpcGetDownloadUrl(e, t, r), c = Je(i, o, n);
|
|
1641
|
-
return this.logger.info(`download blob ${m(e)} from url ${l}, headers: ${JSON.stringify(c)}`),
|
|
1641
|
+
return this.logger.info(`download blob ${m(e)} from url ${l}, headers: ${JSON.stringify(c)}`), Mr(l) ? await this.readLocalFile(l, o, n) : await this.remoteFileDownloader.download(l, c, r);
|
|
1642
1642
|
}
|
|
1643
1643
|
async readLocalFile(e, t, r) {
|
|
1644
|
-
const { storageId: o, relativePath: n } =
|
|
1644
|
+
const { storageId: o, relativePath: n } = Wr(e), l = xr(o, this.localStorageIdsToRoot, n);
|
|
1645
1645
|
return {
|
|
1646
|
-
content:
|
|
1646
|
+
content: Pe.toWeb(Ue.createReadStream(l, { start: t, end: r !== void 0 ? r - 1 : void 0 })),
|
|
1647
1647
|
size: (await w.stat(l)).size
|
|
1648
1648
|
};
|
|
1649
1649
|
}
|
|
@@ -1655,7 +1655,7 @@ class Er {
|
|
|
1655
1655
|
).response;
|
|
1656
1656
|
}
|
|
1657
1657
|
}
|
|
1658
|
-
function
|
|
1658
|
+
function Wr(s) {
|
|
1659
1659
|
const e = new URL(s);
|
|
1660
1660
|
if (e.pathname == "")
|
|
1661
1661
|
throw new Re(`url for local filepath ${s} does not match url scheme`);
|
|
@@ -1664,14 +1664,14 @@ function Fr(s) {
|
|
|
1664
1664
|
relativePath: decodeURIComponent(e.pathname.slice(1))
|
|
1665
1665
|
};
|
|
1666
1666
|
}
|
|
1667
|
-
function
|
|
1667
|
+
function xr(s, e, t) {
|
|
1668
1668
|
const r = e.get(s);
|
|
1669
1669
|
if (r === void 0) throw new Ne(`Unknown storage location: ${s}`);
|
|
1670
1670
|
return r === "" ? t : k.join(r, t);
|
|
1671
1671
|
}
|
|
1672
|
-
const
|
|
1673
|
-
function
|
|
1674
|
-
return s.startsWith(
|
|
1672
|
+
const Ar = "storage://";
|
|
1673
|
+
function Mr(s) {
|
|
1674
|
+
return s.startsWith(Ar);
|
|
1675
1675
|
}
|
|
1676
1676
|
class Re extends Error {
|
|
1677
1677
|
constructor() {
|
|
@@ -1685,13 +1685,13 @@ class Ne extends Error {
|
|
|
1685
1685
|
h(this, "name", "UnknownStorageError");
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
|
-
function
|
|
1688
|
+
function Hr(s) {
|
|
1689
1689
|
const e = /* @__PURE__ */ new Map();
|
|
1690
1690
|
for (const t of s)
|
|
1691
1691
|
t.localPath !== "" && E(t.localPath), e.set(t.storageId, t.localPath);
|
|
1692
1692
|
return e;
|
|
1693
1693
|
}
|
|
1694
|
-
class
|
|
1694
|
+
class jr extends g {
|
|
1695
1695
|
constructor() {
|
|
1696
1696
|
super("google.protobuf.Timestamp", [
|
|
1697
1697
|
{
|
|
@@ -1798,8 +1798,8 @@ class Ar extends g {
|
|
|
1798
1798
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1799
1799
|
}
|
|
1800
1800
|
}
|
|
1801
|
-
const ie = new
|
|
1802
|
-
class
|
|
1801
|
+
const ie = new jr();
|
|
1802
|
+
class Gr extends g {
|
|
1803
1803
|
constructor() {
|
|
1804
1804
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
1805
1805
|
}
|
|
@@ -1827,8 +1827,8 @@ class Mr extends g {
|
|
|
1827
1827
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1828
1828
|
}
|
|
1829
1829
|
}
|
|
1830
|
-
new
|
|
1831
|
-
class
|
|
1830
|
+
new Gr();
|
|
1831
|
+
class Vr extends g {
|
|
1832
1832
|
constructor() {
|
|
1833
1833
|
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
1834
1834
|
{
|
|
@@ -1930,8 +1930,8 @@ class Hr extends g {
|
|
|
1930
1930
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1931
1931
|
}
|
|
1932
1932
|
}
|
|
1933
|
-
const ae = new
|
|
1934
|
-
class
|
|
1933
|
+
const ae = new Vr();
|
|
1934
|
+
class qr extends g {
|
|
1935
1935
|
constructor() {
|
|
1936
1936
|
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
1937
1937
|
}
|
|
@@ -1959,8 +1959,8 @@ class jr extends g {
|
|
|
1959
1959
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
|
-
new
|
|
1963
|
-
class
|
|
1962
|
+
new qr();
|
|
1963
|
+
class Jr extends g {
|
|
1964
1964
|
constructor() {
|
|
1965
1965
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
1966
1966
|
{
|
|
@@ -2013,8 +2013,8 @@ class Gr extends g {
|
|
|
2013
2013
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
const
|
|
2017
|
-
class
|
|
2016
|
+
const Zr = new Jr();
|
|
2017
|
+
class Qr extends g {
|
|
2018
2018
|
constructor() {
|
|
2019
2019
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2020
2020
|
{ no: 1, name: "items", kind: "message", repeat: 2, T: () => ae },
|
|
@@ -2062,10 +2062,10 @@ class qr extends g {
|
|
|
2062
2062
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2063
2063
|
}
|
|
2064
2064
|
}
|
|
2065
|
-
const
|
|
2066
|
-
{ name: "List", options: {}, I:
|
|
2065
|
+
const Kr = new Qr(), le = new O("MiLaboratories.Controller.Shared.LS", [
|
|
2066
|
+
{ name: "List", options: {}, I: Zr, O: Kr }
|
|
2067
2067
|
]);
|
|
2068
|
-
class
|
|
2068
|
+
class Xr {
|
|
2069
2069
|
constructor(e) {
|
|
2070
2070
|
h(this, "typeName", le.typeName);
|
|
2071
2071
|
h(this, "methods", le.methods);
|
|
@@ -2080,10 +2080,10 @@ class Zr {
|
|
|
2080
2080
|
return P("unary", this._transport, r, o, e);
|
|
2081
2081
|
}
|
|
2082
2082
|
}
|
|
2083
|
-
class
|
|
2083
|
+
class Yr {
|
|
2084
2084
|
constructor(e, t) {
|
|
2085
2085
|
h(this, "grpcClient");
|
|
2086
|
-
this.logger = t, this.grpcClient = e.createGrpcClientProvider((r) => new
|
|
2086
|
+
this.logger = t, this.grpcClient = e.createGrpcClientProvider((r) => new Xr(r));
|
|
2087
2087
|
}
|
|
2088
2088
|
close() {
|
|
2089
2089
|
}
|
|
@@ -2097,7 +2097,7 @@ class Qr {
|
|
|
2097
2097
|
).response;
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
2100
|
-
class
|
|
2100
|
+
class eo extends g {
|
|
2101
2101
|
constructor() {
|
|
2102
2102
|
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2103
2103
|
}
|
|
@@ -2125,8 +2125,8 @@ class Kr extends g {
|
|
|
2125
2125
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2126
2126
|
}
|
|
2127
2127
|
}
|
|
2128
|
-
new
|
|
2129
|
-
class
|
|
2128
|
+
new eo();
|
|
2129
|
+
class to extends g {
|
|
2130
2130
|
constructor() {
|
|
2131
2131
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2132
2132
|
{
|
|
@@ -2205,8 +2205,8 @@ class Xr extends g {
|
|
|
2205
2205
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2206
2206
|
}
|
|
2207
2207
|
}
|
|
2208
|
-
const
|
|
2209
|
-
class
|
|
2208
|
+
const ro = new to();
|
|
2209
|
+
class oo extends g {
|
|
2210
2210
|
constructor() {
|
|
2211
2211
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2212
2212
|
{
|
|
@@ -2272,8 +2272,8 @@ class eo extends g {
|
|
|
2272
2272
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2273
2273
|
}
|
|
2274
2274
|
}
|
|
2275
|
-
const
|
|
2276
|
-
class
|
|
2275
|
+
const no = new oo();
|
|
2276
|
+
class so extends g {
|
|
2277
2277
|
constructor() {
|
|
2278
2278
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2279
2279
|
{
|
|
@@ -2364,8 +2364,8 @@ class ro extends g {
|
|
|
2364
2364
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
2367
|
-
const
|
|
2368
|
-
class
|
|
2367
|
+
const io = new so();
|
|
2368
|
+
class ao extends g {
|
|
2369
2369
|
constructor() {
|
|
2370
2370
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2371
2371
|
{
|
|
@@ -2456,8 +2456,8 @@ class no extends g {
|
|
|
2456
2456
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
|
-
const
|
|
2460
|
-
class
|
|
2459
|
+
const lo = new ao();
|
|
2460
|
+
class co extends g {
|
|
2461
2461
|
constructor() {
|
|
2462
2462
|
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2463
2463
|
{
|
|
@@ -2548,8 +2548,8 @@ class io extends g {
|
|
|
2548
2548
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2549
2549
|
}
|
|
2550
2550
|
}
|
|
2551
|
-
const
|
|
2552
|
-
class
|
|
2551
|
+
const ho = new co();
|
|
2552
|
+
class uo extends g {
|
|
2553
2553
|
constructor() {
|
|
2554
2554
|
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2555
2555
|
{
|
|
@@ -2614,14 +2614,14 @@ class lo extends g {
|
|
|
2614
2614
|
return o !== !1 && (o == !0 ? u.onWrite : o)(this.typeName, e, t), t;
|
|
2615
2615
|
}
|
|
2616
2616
|
}
|
|
2617
|
-
const C = new
|
|
2618
|
-
{ name: "StreamBinary", serverStreaming: !0, options: {}, I:
|
|
2619
|
-
{ name: "ReadBinary", options: {}, I:
|
|
2620
|
-
{ name: "StreamText", serverStreaming: !0, options: {}, I:
|
|
2621
|
-
{ name: "ReadText", options: {}, I:
|
|
2622
|
-
{ name: "LastLines", options: {}, I:
|
|
2617
|
+
const C = new uo(), ce = new O("MiLaboratories.Controller.Shared.Streaming", [
|
|
2618
|
+
{ name: "StreamBinary", serverStreaming: !0, options: {}, I: ro, O: C },
|
|
2619
|
+
{ name: "ReadBinary", options: {}, I: no, O: C },
|
|
2620
|
+
{ name: "StreamText", serverStreaming: !0, options: {}, I: io, O: C },
|
|
2621
|
+
{ name: "ReadText", options: {}, I: lo, O: C },
|
|
2622
|
+
{ name: "LastLines", options: {}, I: ho, O: C }
|
|
2623
2623
|
]);
|
|
2624
|
-
class
|
|
2624
|
+
class po {
|
|
2625
2625
|
constructor(e) {
|
|
2626
2626
|
h(this, "typeName", ce.typeName);
|
|
2627
2627
|
h(this, "methods", ce.methods);
|
|
@@ -2690,10 +2690,10 @@ class co {
|
|
|
2690
2690
|
return P("unary", this._transport, r, o, e);
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
|
-
class
|
|
2693
|
+
class go {
|
|
2694
2694
|
constructor(e, t, r) {
|
|
2695
2695
|
h(this, "grpcClient");
|
|
2696
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((o) => new
|
|
2696
|
+
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((o) => new po(o));
|
|
2697
2697
|
}
|
|
2698
2698
|
close() {
|
|
2699
2699
|
}
|
|
@@ -2726,41 +2726,41 @@ class ho {
|
|
|
2726
2726
|
)).response;
|
|
2727
2727
|
}
|
|
2728
2728
|
}
|
|
2729
|
-
function
|
|
2729
|
+
function Xn(s, e, t) {
|
|
2730
2730
|
return e.getDriver({
|
|
2731
2731
|
name: "DownloadBlob",
|
|
2732
|
-
init: (r, o, n) => new
|
|
2732
|
+
init: (r, o, n) => new zr(o, n, s, t)
|
|
2733
2733
|
});
|
|
2734
2734
|
}
|
|
2735
|
-
function
|
|
2735
|
+
function Yn(s, e) {
|
|
2736
2736
|
return s.getDriver({
|
|
2737
2737
|
name: "StreamLogs",
|
|
2738
|
-
init: (t, r, o) => new
|
|
2738
|
+
init: (t, r, o) => new go(r, o, e)
|
|
2739
2739
|
});
|
|
2740
2740
|
}
|
|
2741
|
-
function
|
|
2741
|
+
function es(s, e) {
|
|
2742
2742
|
return s.getDriver({
|
|
2743
2743
|
name: "UploadProgress",
|
|
2744
|
-
init: (t, r, o) => new
|
|
2744
|
+
init: (t, r, o) => new Sr(r, o, s, e)
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
|
-
function
|
|
2747
|
+
function ts(s, e) {
|
|
2748
2748
|
return s.getDriver({
|
|
2749
2749
|
name: "UploadBlob",
|
|
2750
|
-
init: (t, r, o) => new
|
|
2750
|
+
init: (t, r, o) => new cr(r, o, s, e)
|
|
2751
2751
|
});
|
|
2752
2752
|
}
|
|
2753
|
-
function
|
|
2753
|
+
function fo(s, e) {
|
|
2754
2754
|
return s.getDriver({
|
|
2755
2755
|
name: "LsFiles",
|
|
2756
|
-
init: (t, r, o) => new
|
|
2756
|
+
init: (t, r, o) => new Yr(r, e)
|
|
2757
2757
|
});
|
|
2758
2758
|
}
|
|
2759
2759
|
const et = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
2760
|
-
function
|
|
2760
|
+
function wo(s, e) {
|
|
2761
2761
|
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
2762
2762
|
}
|
|
2763
|
-
function
|
|
2763
|
+
function mo(s) {
|
|
2764
2764
|
return !!s.match(et);
|
|
2765
2765
|
}
|
|
2766
2766
|
function he(s, e) {
|
|
@@ -2770,7 +2770,7 @@ function he(s, e) {
|
|
|
2770
2770
|
const { path: r, signature: o } = t.groups;
|
|
2771
2771
|
return e.verify(r, o, `Signature verification failed for: ${s}`), { path: r, signature: o };
|
|
2772
2772
|
}
|
|
2773
|
-
const
|
|
2773
|
+
const yo = K({
|
|
2774
2774
|
kv: {
|
|
2775
2775
|
"ctl/file/blobInfo": T.object({
|
|
2776
2776
|
sizeBytes: T.coerce.number()
|
|
@@ -2801,27 +2801,27 @@ const Y = T.object({
|
|
|
2801
2801
|
storageId: T.string(),
|
|
2802
2802
|
/** Path inside storage */
|
|
2803
2803
|
path: T.string()
|
|
2804
|
-
}),
|
|
2804
|
+
}), rs = T.union([
|
|
2805
2805
|
Y,
|
|
2806
2806
|
rt
|
|
2807
|
-
]),
|
|
2807
|
+
]), bo = K({
|
|
2808
2808
|
data: Y,
|
|
2809
2809
|
fields: {
|
|
2810
2810
|
blob: !1
|
|
2811
2811
|
}
|
|
2812
|
-
}),
|
|
2812
|
+
}), ko = K({
|
|
2813
2813
|
fields: {
|
|
2814
2814
|
incarnation: !1
|
|
2815
2815
|
}
|
|
2816
2816
|
}), ot = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.+)\/(?<resourceVersion>.+?)\/(?<resourceId>\d+?)\/(?<size>\d+?))#(?<signature>.*)$/;
|
|
2817
|
-
function
|
|
2817
|
+
function To(s, e) {
|
|
2818
2818
|
let t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}/${tt(s)}`;
|
|
2819
2819
|
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
2820
2820
|
}
|
|
2821
|
-
function
|
|
2821
|
+
function Lo(s) {
|
|
2822
2822
|
return !!s.match(ot);
|
|
2823
2823
|
}
|
|
2824
|
-
function
|
|
2824
|
+
function Uo(s, e) {
|
|
2825
2825
|
const t = s.match(ot);
|
|
2826
2826
|
if (t === null)
|
|
2827
2827
|
throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
@@ -2840,7 +2840,7 @@ class $e extends Error {
|
|
|
2840
2840
|
h(this, "name", "WrongResourceTypeError");
|
|
2841
2841
|
}
|
|
2842
2842
|
}
|
|
2843
|
-
class
|
|
2843
|
+
class Po {
|
|
2844
2844
|
constructor(e) {
|
|
2845
2845
|
h(this, "updating");
|
|
2846
2846
|
this.onUpdate = e;
|
|
@@ -2865,14 +2865,14 @@ function V(s) {
|
|
|
2865
2865
|
return st.test(s);
|
|
2866
2866
|
}
|
|
2867
2867
|
const it = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
2868
|
-
function
|
|
2868
|
+
function Ro(s) {
|
|
2869
2869
|
return it.test(s);
|
|
2870
2870
|
}
|
|
2871
2871
|
function q(s) {
|
|
2872
2872
|
let e;
|
|
2873
2873
|
if (V(s))
|
|
2874
2874
|
e = s.match(st);
|
|
2875
|
-
else if (
|
|
2875
|
+
else if (Ro(s))
|
|
2876
2876
|
e = s.match(it);
|
|
2877
2877
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
2878
2878
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
@@ -2888,7 +2888,7 @@ function b(s) {
|
|
|
2888
2888
|
function Be(s) {
|
|
2889
2889
|
return k.basename(s);
|
|
2890
2890
|
}
|
|
2891
|
-
class
|
|
2891
|
+
class No {
|
|
2892
2892
|
constructor(e, t, r, o, n) {
|
|
2893
2893
|
h(this, "change", new B());
|
|
2894
2894
|
h(this, "signalCtl", new AbortController());
|
|
@@ -2915,9 +2915,9 @@ class Po {
|
|
|
2915
2915
|
async download() {
|
|
2916
2916
|
try {
|
|
2917
2917
|
const e = await this.ensureDownloaded();
|
|
2918
|
-
this.setDone(e), this.change.markChanged(`blob download for ${
|
|
2918
|
+
this.setDone(e), this.change.markChanged(`blob download for ${U(this.rInfo.id)} finished`);
|
|
2919
2919
|
} catch (e) {
|
|
2920
|
-
throw this.logger.error(`download blob ${m(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`), Se(e) && (this.setError(e), this.change.markChanged(`blob download for ${
|
|
2920
|
+
throw this.logger.error(`download blob ${m(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`), Se(e) && (this.setError(e), this.change.markChanged(`blob download for ${U(this.rInfo.id)} failed`), await w.rm(this.path, { force: !0 })), e;
|
|
2921
2921
|
}
|
|
2922
2922
|
}
|
|
2923
2923
|
async ensureDownloaded() {
|
|
@@ -2934,7 +2934,7 @@ class Po {
|
|
|
2934
2934
|
this.signalCtl.signal
|
|
2935
2935
|
);
|
|
2936
2936
|
return this.state.fileSize = r, this.state.downloaded = !0, await Z(this.logger, this.state.filePath, async (o) => {
|
|
2937
|
-
const n =
|
|
2937
|
+
const n = I.toWeb(fe.createWriteStream(o, { flags: "wx" }));
|
|
2938
2938
|
await t.pipeTo(n, { signal: this.signalCtl.signal }), this.state.tempWritten = !0;
|
|
2939
2939
|
}), this.state.done = !0, r;
|
|
2940
2940
|
}
|
|
@@ -2944,7 +2944,7 @@ class Po {
|
|
|
2944
2944
|
getBlob() {
|
|
2945
2945
|
return this.done ? {
|
|
2946
2946
|
done: this.done,
|
|
2947
|
-
result:
|
|
2947
|
+
result: $o(this.handle, this.size, this.error)
|
|
2948
2948
|
} : { done: !1 };
|
|
2949
2949
|
}
|
|
2950
2950
|
setDone(e) {
|
|
@@ -2963,7 +2963,7 @@ class at extends Error {
|
|
|
2963
2963
|
h(this, "name", "DownloadAborted");
|
|
2964
2964
|
}
|
|
2965
2965
|
}
|
|
2966
|
-
function
|
|
2966
|
+
function $o(s, e, t) {
|
|
2967
2967
|
return t ? { ok: !1, error: t } : s ? {
|
|
2968
2968
|
ok: !0,
|
|
2969
2969
|
value: {
|
|
@@ -2972,7 +2972,7 @@ function Uo(s, e, t) {
|
|
|
2972
2972
|
}
|
|
2973
2973
|
} : { ok: !1, error: new Error("No file or handle provided") };
|
|
2974
2974
|
}
|
|
2975
|
-
class
|
|
2975
|
+
class Ie {
|
|
2976
2976
|
constructor(e) {
|
|
2977
2977
|
h(this, "cache", /* @__PURE__ */ new Map());
|
|
2978
2978
|
h(this, "totalSizeBytes", 0);
|
|
@@ -3012,17 +3012,17 @@ class De {
|
|
|
3012
3012
|
this.cache.delete(e.path), this.totalSizeBytes -= e.size;
|
|
3013
3013
|
}
|
|
3014
3014
|
}
|
|
3015
|
-
const
|
|
3016
|
-
ranges: T.array(
|
|
3017
|
-
}),
|
|
3018
|
-
function
|
|
3019
|
-
return s +
|
|
3015
|
+
const So = T.object({
|
|
3016
|
+
ranges: T.array($t)
|
|
3017
|
+
}), Io = ".ranges.json";
|
|
3018
|
+
function Do(s) {
|
|
3019
|
+
return s + Io;
|
|
3020
3020
|
}
|
|
3021
|
-
async function
|
|
3021
|
+
async function vo(s, e) {
|
|
3022
3022
|
let t = { ranges: [] };
|
|
3023
3023
|
try {
|
|
3024
3024
|
const r = await w.readFile(e, "utf8");
|
|
3025
|
-
t =
|
|
3025
|
+
t = So.parse(JSON.parse(r));
|
|
3026
3026
|
} catch (r) {
|
|
3027
3027
|
if (r instanceof SyntaxError || r instanceof T.ZodError) {
|
|
3028
3028
|
const o = `readRangesFile: the file ${e} was corrupted: ${r}`;
|
|
@@ -3033,7 +3033,7 @@ async function So(s, e) {
|
|
|
3033
3033
|
}
|
|
3034
3034
|
return lt(t), t;
|
|
3035
3035
|
}
|
|
3036
|
-
async function
|
|
3036
|
+
async function Bo(s, e, t) {
|
|
3037
3037
|
await Z(s, e, async (r) => {
|
|
3038
3038
|
await w.writeFile(r, JSON.stringify(t, null, 2), { flag: "wx" });
|
|
3039
3039
|
});
|
|
@@ -3041,36 +3041,36 @@ async function Do(s, e, t) {
|
|
|
3041
3041
|
function lt(s) {
|
|
3042
3042
|
s.ranges.sort((e, t) => e.from - t.from);
|
|
3043
3043
|
for (let e = 0; e < s.ranges.length - 1; e++)
|
|
3044
|
-
s.ranges[e].to >= s.ranges[e + 1].from && (
|
|
3044
|
+
s.ranges[e].to >= s.ranges[e + 1].from && (Co(s, e), e--);
|
|
3045
3045
|
}
|
|
3046
|
-
function
|
|
3046
|
+
function Co(s, e) {
|
|
3047
3047
|
const t = Math.min(s.ranges[e].from, s.ranges[e + 1].from), r = Math.max(s.ranges[e].to, s.ranges[e + 1].to);
|
|
3048
3048
|
s.ranges.splice(e, 2, { from: t, to: r });
|
|
3049
3049
|
}
|
|
3050
3050
|
function x(s) {
|
|
3051
3051
|
return s.ranges.reduce((e, t) => e + t.to - t.from, 0);
|
|
3052
3052
|
}
|
|
3053
|
-
function
|
|
3053
|
+
function _o(s, e) {
|
|
3054
3054
|
for (const t of s.ranges)
|
|
3055
3055
|
if (t.from <= e.from && e.to <= t.to)
|
|
3056
3056
|
return !0;
|
|
3057
3057
|
return !1;
|
|
3058
3058
|
}
|
|
3059
|
-
function
|
|
3059
|
+
function Eo(s, e) {
|
|
3060
3060
|
return s.ranges.push(e), lt(s), s;
|
|
3061
3061
|
}
|
|
3062
|
-
async function
|
|
3062
|
+
async function Fo(s, e, t) {
|
|
3063
3063
|
try {
|
|
3064
|
-
await (await w.open(e, "w")).close(), await
|
|
3064
|
+
await (await w.open(e, "w")).close(), await Oo(e, t);
|
|
3065
3065
|
} catch (r) {
|
|
3066
3066
|
s.error(`Error creating file ${e} on platform ${t}: ${r}`);
|
|
3067
3067
|
}
|
|
3068
3068
|
}
|
|
3069
|
-
async function
|
|
3069
|
+
async function Oo(s, e) {
|
|
3070
3070
|
e === "win32" && await Pt("fsutil", ["sparse", "setflag", `"${s}"`], { stdio: "pipe" });
|
|
3071
3071
|
}
|
|
3072
|
-
async function
|
|
3073
|
-
await z(t) || await
|
|
3072
|
+
async function zo(s, e, t, r, o) {
|
|
3073
|
+
await z(t) || await Fo(s, t, e);
|
|
3074
3074
|
const n = await w.open(t, "r+");
|
|
3075
3075
|
await n.write(r, 0, r.length, o), await n.close();
|
|
3076
3076
|
}
|
|
@@ -3080,24 +3080,24 @@ class ct extends Error {
|
|
|
3080
3080
|
h(this, "name", "CorruptedRangesError");
|
|
3081
3081
|
}
|
|
3082
3082
|
}
|
|
3083
|
-
class
|
|
3083
|
+
class Wo {
|
|
3084
3084
|
constructor(e, t) {
|
|
3085
3085
|
this.logger = e, this.cacheDir = t;
|
|
3086
3086
|
}
|
|
3087
3087
|
fPath(e) {
|
|
3088
|
-
return
|
|
3088
|
+
return L.join(this.cacheDir, Do(e));
|
|
3089
3089
|
}
|
|
3090
3090
|
async get(e) {
|
|
3091
|
-
return await
|
|
3091
|
+
return await vo(this.logger, this.fPath(e));
|
|
3092
3092
|
}
|
|
3093
3093
|
async set(e, t) {
|
|
3094
|
-
return await
|
|
3094
|
+
return await Bo(this.logger, this.fPath(e), t);
|
|
3095
3095
|
}
|
|
3096
3096
|
async delete(e) {
|
|
3097
3097
|
await we.rm(this.fPath(e));
|
|
3098
3098
|
}
|
|
3099
3099
|
}
|
|
3100
|
-
class
|
|
3100
|
+
class xo {
|
|
3101
3101
|
constructor(e, t) {
|
|
3102
3102
|
h(this, "suffix", ".sparse.bin");
|
|
3103
3103
|
this.logger = e, this.cacheDir = t;
|
|
@@ -3109,20 +3109,20 @@ class Oo {
|
|
|
3109
3109
|
return await z(this.path(e));
|
|
3110
3110
|
}
|
|
3111
3111
|
path(e) {
|
|
3112
|
-
return
|
|
3112
|
+
return L.join(this.cacheDir, e + this.suffix);
|
|
3113
3113
|
}
|
|
3114
3114
|
async write(e, t, r) {
|
|
3115
|
-
await F(this.cacheDir), await
|
|
3115
|
+
await F(this.cacheDir), await zo(this.logger, process.platform, this.path(e), t, r);
|
|
3116
3116
|
}
|
|
3117
3117
|
async delete(e) {
|
|
3118
3118
|
await we.rm(this.path(e));
|
|
3119
3119
|
}
|
|
3120
3120
|
}
|
|
3121
|
-
class
|
|
3121
|
+
class Ao {
|
|
3122
3122
|
constructor(e, t, r, o) {
|
|
3123
3123
|
/** Fields are public for tests. */
|
|
3124
3124
|
/** The lock to make sure cache requests are done one by one. */
|
|
3125
|
-
h(this, "lock", new
|
|
3125
|
+
h(this, "lock", new Et.AwaitLock());
|
|
3126
3126
|
h(this, "keyToLastAccessTime", /* @__PURE__ */ new Map());
|
|
3127
3127
|
h(this, "size", 0);
|
|
3128
3128
|
this.logger = e, this.maxSize = t, this.ranges = r, this.storage = o;
|
|
@@ -3158,7 +3158,7 @@ class zo {
|
|
|
3158
3158
|
if (await this.storage.exists(e)) {
|
|
3159
3159
|
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3160
3160
|
const r = await this.getRanges(e);
|
|
3161
|
-
return
|
|
3161
|
+
return _o(r, t) ? this.storage.path(e) : void 0;
|
|
3162
3162
|
}
|
|
3163
3163
|
}
|
|
3164
3164
|
async setUnsafe(e, t, r) {
|
|
@@ -3173,7 +3173,7 @@ class zo {
|
|
|
3173
3173
|
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3174
3174
|
const o = await this.getRanges(e);
|
|
3175
3175
|
this.size -= x(o), await this.storage.write(e, r, t.from);
|
|
3176
|
-
const n =
|
|
3176
|
+
const n = Eo(o, t);
|
|
3177
3177
|
this.size += x(n), await this.ranges.set(e, n);
|
|
3178
3178
|
}
|
|
3179
3179
|
/** Ensures the size is less than hard limit by deleting the oldest keys. */
|
|
@@ -3223,9 +3223,9 @@ class ht {
|
|
|
3223
3223
|
h(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3224
3224
|
h(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3225
3225
|
h(this, "saveDir");
|
|
3226
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.rangesCacheDir = n, this.signer = l, this.ops = i, this.cache = new
|
|
3227
|
-
const c = new
|
|
3228
|
-
this.rangesCache = new
|
|
3226
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.rangesCacheDir = n, this.signer = l, this.ops = i, this.cache = new Ie(this.ops.cacheSoftSizeBytes);
|
|
3227
|
+
const c = new Wo(this.logger, this.rangesCacheDir), a = new xo(this.logger, this.rangesCacheDir);
|
|
3228
|
+
this.rangesCache = new Ao(this.logger, this.ops.rangesCacheMaxSizeBytes, c, a), this.downloadQueue = new Q(this.logger, i.nConcurrentDownloads), this.saveDir = k.resolve(o);
|
|
3229
3229
|
}
|
|
3230
3230
|
static async init(e, t, r, o, n, l, i) {
|
|
3231
3231
|
const c = new ht(e, t, r, o, n, l, i);
|
|
@@ -3254,11 +3254,11 @@ class ht {
|
|
|
3254
3254
|
const r = b(e.id), o = this.keyToDownload.get(r);
|
|
3255
3255
|
if (o)
|
|
3256
3256
|
return o;
|
|
3257
|
-
const n = k.resolve(this.saveDir, r), l = new
|
|
3257
|
+
const n = k.resolve(this.saveDir, r), l = new No(
|
|
3258
3258
|
this.logger,
|
|
3259
3259
|
this.clientDownload,
|
|
3260
3260
|
e,
|
|
3261
|
-
|
|
3261
|
+
wo(n, this.signer),
|
|
3262
3262
|
n
|
|
3263
3263
|
);
|
|
3264
3264
|
return this.keyToDownload.set(r, l), this.downloadQueue.push({
|
|
@@ -3273,13 +3273,13 @@ class ht {
|
|
|
3273
3273
|
}
|
|
3274
3274
|
getOnDemandBlob(e, t) {
|
|
3275
3275
|
if (t === void 0) return y.make((l) => this.getOnDemandBlob(e, l));
|
|
3276
|
-
const r = W(e) ? G(e,
|
|
3276
|
+
const r = W(e) ? G(e, yo, t) : e, o = N();
|
|
3277
3277
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(r.id, o)), this.getOnDemandBlobNoCtx(r, o);
|
|
3278
3278
|
}
|
|
3279
3279
|
getOnDemandBlobNoCtx(e, t) {
|
|
3280
3280
|
_("getOnDemandBlob", e.type);
|
|
3281
3281
|
let r = this.keyToOnDemand.get(b(e.id));
|
|
3282
|
-
return r === void 0 && (r = new
|
|
3282
|
+
return r === void 0 && (r = new Mo(tt(e), To(e, this.signer)), this.keyToOnDemand.set(b(e.id), r)), r.attach(t), r.getHandle();
|
|
3283
3283
|
}
|
|
3284
3284
|
/** Gets a path from a handle. */
|
|
3285
3285
|
getLocalPath(e) {
|
|
@@ -3288,10 +3288,10 @@ class ht {
|
|
|
3288
3288
|
}
|
|
3289
3289
|
/** Gets a content of a blob by a handle. */
|
|
3290
3290
|
async getContent(e, t) {
|
|
3291
|
-
if (t &&
|
|
3291
|
+
if (t && De(t, "getContent"), mo(e))
|
|
3292
3292
|
return await _e(this.getLocalPath(e), t);
|
|
3293
|
-
if (
|
|
3294
|
-
const r =
|
|
3293
|
+
if (Lo(e)) {
|
|
3294
|
+
const r = Uo(e, this.signer), o = b(r.info.id), n = await this.rangesCache.get(o, t ?? { from: 0, to: r.size });
|
|
3295
3295
|
if (n)
|
|
3296
3296
|
return await _e(n, t);
|
|
3297
3297
|
const { content: l } = await this.clientDownload.downloadBlob(
|
|
@@ -3310,7 +3310,7 @@ class ht {
|
|
|
3310
3310
|
* Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
|
|
3311
3311
|
*/
|
|
3312
3312
|
getComputableContent(e, t) {
|
|
3313
|
-
return t &&
|
|
3313
|
+
return t && De(t, "getComputableContent"), y.make(
|
|
3314
3314
|
(r) => this.getDownloadedBlob(e, r),
|
|
3315
3315
|
{
|
|
3316
3316
|
postprocessValue: (r) => r ? this.getContent(r.handle, t) : void 0
|
|
@@ -3432,11 +3432,11 @@ class ht {
|
|
|
3432
3432
|
/** Removes all files from a hard drive. */
|
|
3433
3433
|
async releaseAll() {
|
|
3434
3434
|
this.downloadQueue.stop(), this.keyToDownload.forEach((e, t) => {
|
|
3435
|
-
this.keyToDownload.delete(t), e.change.markChanged(`task ${
|
|
3435
|
+
this.keyToDownload.delete(t), e.change.markChanged(`task ${U(e.rInfo.id)} released`);
|
|
3436
3436
|
});
|
|
3437
3437
|
}
|
|
3438
3438
|
}
|
|
3439
|
-
class
|
|
3439
|
+
class Mo {
|
|
3440
3440
|
constructor(e, t) {
|
|
3441
3441
|
h(this, "counter", new v());
|
|
3442
3442
|
this.size = e, this.handle = t;
|
|
@@ -3457,7 +3457,7 @@ class Ce {
|
|
|
3457
3457
|
h(this, "log");
|
|
3458
3458
|
h(this, "change", new B());
|
|
3459
3459
|
h(this, "error");
|
|
3460
|
-
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new
|
|
3460
|
+
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new Po(async () => this.update());
|
|
3461
3461
|
}
|
|
3462
3462
|
getOrSchedule(e) {
|
|
3463
3463
|
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
@@ -3467,7 +3467,7 @@ class Ce {
|
|
|
3467
3467
|
}
|
|
3468
3468
|
async update() {
|
|
3469
3469
|
try {
|
|
3470
|
-
const e = await
|
|
3470
|
+
const e = await Ho(this.path, this.lines, this.patternToSearch);
|
|
3471
3471
|
this.log != e && this.change.markChanged(`logs for ${this.path} updated`), this.log = e;
|
|
3472
3472
|
} catch (e) {
|
|
3473
3473
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
@@ -3478,10 +3478,10 @@ class Ce {
|
|
|
3478
3478
|
}
|
|
3479
3479
|
}
|
|
3480
3480
|
}
|
|
3481
|
-
function
|
|
3482
|
-
const r =
|
|
3481
|
+
function Ho(s, e, t) {
|
|
3482
|
+
const r = Ue.createReadStream(s), o = new I();
|
|
3483
3483
|
return new Promise((n, l) => {
|
|
3484
|
-
const i =
|
|
3484
|
+
const i = _t.createInterface(r, o), c = new vt();
|
|
3485
3485
|
i.on("line", function(a) {
|
|
3486
3486
|
t != null && !a.includes(t) || (c.push(a), c.length > e && c.shift());
|
|
3487
3487
|
}), i.on("error", l), i.on("close", function() {
|
|
@@ -3492,8 +3492,8 @@ function xo(s, e, t) {
|
|
|
3492
3492
|
async function _e(s, e) {
|
|
3493
3493
|
const t = {};
|
|
3494
3494
|
e && (t.start = e.from, t.end = e.to - 1);
|
|
3495
|
-
const r =
|
|
3496
|
-
return await He(
|
|
3495
|
+
const r = Ue.createReadStream(s, t);
|
|
3496
|
+
return await He(Pe.toWeb(r));
|
|
3497
3497
|
}
|
|
3498
3498
|
function _(s, e) {
|
|
3499
3499
|
if (!e.name.startsWith("Blob/")) {
|
|
@@ -3501,31 +3501,39 @@ function _(s, e) {
|
|
|
3501
3501
|
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new $e(t);
|
|
3502
3502
|
}
|
|
3503
3503
|
}
|
|
3504
|
-
const
|
|
3505
|
-
function
|
|
3504
|
+
const jo = K({});
|
|
3505
|
+
function Go(s, e) {
|
|
3506
3506
|
const t = W(s) ? e.accessor(s).node() : Ge(s) ? s.node() : s;
|
|
3507
|
-
return G(t,
|
|
3507
|
+
return G(t, jo);
|
|
3508
3508
|
}
|
|
3509
|
-
function
|
|
3510
|
-
const r =
|
|
3509
|
+
function Vo(s, e, t) {
|
|
3510
|
+
const r = L.relative(e, t);
|
|
3511
3511
|
return `plblob+folder://${s.sign(r)}.${r}.blob`;
|
|
3512
3512
|
}
|
|
3513
|
-
function
|
|
3514
|
-
|
|
3513
|
+
function qo(s, e, t) {
|
|
3514
|
+
const r = L.relative(e, t);
|
|
3515
|
+
return `block-ui://${s.sign(r)}.${r}.uidir`;
|
|
3516
|
+
}
|
|
3517
|
+
function Jo(s, e, t) {
|
|
3518
|
+
return dt(s, e, t);
|
|
3519
|
+
}
|
|
3520
|
+
function Zo(s, e, t) {
|
|
3521
|
+
return dt(s, e, t);
|
|
3515
3522
|
}
|
|
3516
|
-
function
|
|
3523
|
+
function dt(s, e, t) {
|
|
3517
3524
|
const r = new URL(e), [o, n, l] = r.host.split(".");
|
|
3518
3525
|
s.verify(n, o, `signature verification failed for url: ${e}, subfolder: ${n}`);
|
|
3519
|
-
|
|
3520
|
-
|
|
3526
|
+
const i = decodeURIComponent(r.pathname.slice(1));
|
|
3527
|
+
let c = Qo(L.join(t, `${n}`), i);
|
|
3528
|
+
return (r.pathname == "" || r.pathname == "/") && (c = L.join(c, "index.html")), L.resolve(c);
|
|
3521
3529
|
}
|
|
3522
|
-
function
|
|
3523
|
-
const t =
|
|
3530
|
+
function Qo(s, e) {
|
|
3531
|
+
const t = L.resolve(s, e), r = L.resolve(s);
|
|
3524
3532
|
if (!t.startsWith(r))
|
|
3525
3533
|
throw new Error("Path validation failed.");
|
|
3526
3534
|
return t;
|
|
3527
3535
|
}
|
|
3528
|
-
class
|
|
3536
|
+
class Ko {
|
|
3529
3537
|
constructor(e, t, r, o, n, l, i) {
|
|
3530
3538
|
h(this, "counter", new v());
|
|
3531
3539
|
h(this, "change", new B());
|
|
@@ -3555,10 +3563,10 @@ class qo {
|
|
|
3555
3563
|
async download() {
|
|
3556
3564
|
try {
|
|
3557
3565
|
const e = await this.downloadAndDecompress(this.signalCtl.signal);
|
|
3558
|
-
this.setDone(e), this.change.markChanged(`download and decompress for ${
|
|
3566
|
+
this.setDone(e), this.change.markChanged(`download and decompress for ${U(this.rInfo.id)} finished`), this.logger.info(`blob to URL task is done: ${m(this.info())}`);
|
|
3559
3567
|
} catch (e) {
|
|
3560
|
-
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${m(this.info())}`),
|
|
3561
|
-
this.setError(e), this.change.markChanged(`download and decompress for ${
|
|
3568
|
+
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${m(this.info())}`), Xo(e)) {
|
|
3569
|
+
this.setError(e), this.change.markChanged(`download and decompress for ${U(this.rInfo.id)} failed`), await ye(this.path);
|
|
3562
3570
|
return;
|
|
3563
3571
|
}
|
|
3564
3572
|
throw e;
|
|
@@ -3566,8 +3574,8 @@ class qo {
|
|
|
3566
3574
|
}
|
|
3567
3575
|
/** Does the download part and keeps a state of the process. */
|
|
3568
3576
|
async downloadAndDecompress(e) {
|
|
3569
|
-
if (this.state = {}, this.state.parentDir =
|
|
3570
|
-
return await
|
|
3577
|
+
if (this.state = {}, this.state.parentDir = L.dirname(this.path), await F(this.state.parentDir), this.state.fileExisted = await z(this.path), this.state.fileExisted)
|
|
3578
|
+
return await ut(this.path);
|
|
3571
3579
|
const { content: t, size: r } = await this.clientDownload.downloadBlob(
|
|
3572
3580
|
this.rInfo,
|
|
3573
3581
|
{},
|
|
@@ -3577,23 +3585,23 @@ class qo {
|
|
|
3577
3585
|
switch (this.state.tempPath = o, this.state.archiveFormat = this.format, this.format) {
|
|
3578
3586
|
case "tar":
|
|
3579
3587
|
await w.mkdir(o);
|
|
3580
|
-
const n =
|
|
3588
|
+
const n = I.toWeb(me.extract(o));
|
|
3581
3589
|
await t.pipeTo(n, { signal: e });
|
|
3582
3590
|
return;
|
|
3583
3591
|
case "tgz":
|
|
3584
3592
|
await w.mkdir(o);
|
|
3585
|
-
const l = Me.toWeb(Ve.createGunzip()), i =
|
|
3593
|
+
const l = Me.toWeb(Ve.createGunzip()), i = I.toWeb(me.extract(o));
|
|
3586
3594
|
await t.pipeThrough(l, { signal: e }).pipeTo(i, { signal: e });
|
|
3587
3595
|
return;
|
|
3588
3596
|
case "zip":
|
|
3589
3597
|
this.state.zipPath = this.path + ".zip";
|
|
3590
|
-
const c =
|
|
3591
|
-
await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await
|
|
3598
|
+
const c = I.toWeb(fe.createWriteStream(this.state.zipPath));
|
|
3599
|
+
await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await Ft(this.state.zipPath, o, {
|
|
3592
3600
|
filter: (a) => !a.path.endsWith("/")
|
|
3593
3601
|
}), this.state.zipDecompressed = !0, await fe.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
|
|
3594
3602
|
return;
|
|
3595
3603
|
default:
|
|
3596
|
-
|
|
3604
|
+
Ut(this.format);
|
|
3597
3605
|
}
|
|
3598
3606
|
}), this.state.pathCreated = !0, r;
|
|
3599
3607
|
}
|
|
@@ -3602,40 +3610,40 @@ class qo {
|
|
|
3602
3610
|
if (this.error) return { error: this.error };
|
|
3603
3611
|
}
|
|
3604
3612
|
setDone(e) {
|
|
3605
|
-
this.done = !0, this.size = e, this.url =
|
|
3613
|
+
this.done = !0, this.size = e, this.url = Vo(this.signer, this.saveDir, this.path);
|
|
3606
3614
|
}
|
|
3607
3615
|
setError(e) {
|
|
3608
3616
|
this.error = String(e);
|
|
3609
3617
|
}
|
|
3610
3618
|
abort(e) {
|
|
3611
|
-
this.signalCtl.abort(new
|
|
3619
|
+
this.signalCtl.abort(new pt(e));
|
|
3612
3620
|
}
|
|
3613
3621
|
}
|
|
3614
|
-
async function
|
|
3622
|
+
async function ut(s) {
|
|
3615
3623
|
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
3616
3624
|
return (await Promise.all(
|
|
3617
3625
|
e.map(async (r) => {
|
|
3618
|
-
const o =
|
|
3619
|
-
return r.isDirectory() ? await
|
|
3626
|
+
const o = L.join(s, r.name);
|
|
3627
|
+
return r.isDirectory() ? await ut(o) : (await w.stat(o)).size;
|
|
3620
3628
|
})
|
|
3621
3629
|
)).reduce((r, o) => r + o, 0);
|
|
3622
3630
|
}
|
|
3623
3631
|
async function ye(s) {
|
|
3624
3632
|
await w.rm(s, { recursive: !0, force: !0 });
|
|
3625
3633
|
}
|
|
3626
|
-
let
|
|
3634
|
+
let pt = class extends Error {
|
|
3627
3635
|
constructor() {
|
|
3628
3636
|
super(...arguments);
|
|
3629
3637
|
h(this, "name", "URLAborted");
|
|
3630
3638
|
}
|
|
3631
3639
|
};
|
|
3632
|
-
function
|
|
3633
|
-
return s instanceof
|
|
3640
|
+
function Xo(s) {
|
|
3641
|
+
return s instanceof pt || s instanceof X || s instanceof Ne || s instanceof Re || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
|
|
3634
3642
|
}
|
|
3635
3643
|
function A(s, e) {
|
|
3636
3644
|
return `id:${String(BigInt(s))}-${e}`;
|
|
3637
3645
|
}
|
|
3638
|
-
class
|
|
3646
|
+
class ns {
|
|
3639
3647
|
constructor(e, t, r, o, n = {
|
|
3640
3648
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
3641
3649
|
nConcurrentDownloads: 50
|
|
@@ -3651,7 +3659,7 @@ class es {
|
|
|
3651
3659
|
maxDelay: 3e4,
|
|
3652
3660
|
backoffMultiplier: 1.5,
|
|
3653
3661
|
jitter: 0.5
|
|
3654
|
-
}), this.cache = new
|
|
3662
|
+
}), this.cache = new Ie(this.opts.cacheSoftSizeBytes);
|
|
3655
3663
|
}
|
|
3656
3664
|
info() {
|
|
3657
3665
|
return {
|
|
@@ -3666,14 +3674,14 @@ class es {
|
|
|
3666
3674
|
* @returns full path to the referenced file
|
|
3667
3675
|
*/
|
|
3668
3676
|
getPathForCustomProtocol(e) {
|
|
3669
|
-
if (
|
|
3670
|
-
return
|
|
3677
|
+
if (St(e))
|
|
3678
|
+
return Jo(this.signer, e, this.saveDir);
|
|
3671
3679
|
throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
|
|
3672
3680
|
}
|
|
3673
3681
|
extractArchiveAndGetURL(e, t, r) {
|
|
3674
3682
|
if (r === void 0)
|
|
3675
3683
|
return y.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
3676
|
-
const o = W(e) ?
|
|
3684
|
+
const o = W(e) ? Go(e, r) : e, n = N();
|
|
3677
3685
|
r.addOnDestroy(() => this.releasePath(o.id, t, n));
|
|
3678
3686
|
const l = this.extractArchiveAndGetURLNoCtx(o, t, r.watcher, n);
|
|
3679
3687
|
if ((l == null ? void 0 : l.url) === void 0 && r.markUnstable(
|
|
@@ -3730,7 +3738,7 @@ class es {
|
|
|
3730
3738
|
);
|
|
3731
3739
|
}
|
|
3732
3740
|
setNewTask(e, t, r, o) {
|
|
3733
|
-
const n = new
|
|
3741
|
+
const n = new Ko(
|
|
3734
3742
|
this.logger,
|
|
3735
3743
|
this.signer,
|
|
3736
3744
|
this.saveDir,
|
|
@@ -3742,13 +3750,13 @@ class es {
|
|
|
3742
3750
|
return n.attach(e, o), this.idToDownload.set(A(t.id, r), n), n;
|
|
3743
3751
|
}
|
|
3744
3752
|
removeTask(e, t) {
|
|
3745
|
-
e.abort(t), e.change.markChanged(`task for ${
|
|
3753
|
+
e.abort(t), e.change.markChanged(`task for ${U(e.rInfo.id)} removed: ${t}`), this.idToDownload.delete(A(e.rInfo.id, e.format));
|
|
3746
3754
|
}
|
|
3747
3755
|
getFilePath(e, t) {
|
|
3748
3756
|
return k.join(this.saveDir, `${String(BigInt(e))}_${t}`);
|
|
3749
3757
|
}
|
|
3750
3758
|
}
|
|
3751
|
-
class
|
|
3759
|
+
class Yo {
|
|
3752
3760
|
constructor(e, t, r, o, n, l) {
|
|
3753
3761
|
h(this, "change", new B());
|
|
3754
3762
|
h(this, "counter", new v());
|
|
@@ -3765,21 +3773,21 @@ class Zo {
|
|
|
3765
3773
|
* At this case, the task will show progress == 1.0. */
|
|
3766
3774
|
h(this, "alreadyExisted", !1);
|
|
3767
3775
|
this.logger = e, this.clientBlob = t, this.clientProgress = r, this.maxNConcurrentPartsUpload = o, this.res = l, this.nMaxUploads = this.maxNConcurrentPartsUpload;
|
|
3768
|
-
const { uploadData: i, progress: c } =
|
|
3776
|
+
const { uploadData: i, progress: c } = tn(l, n);
|
|
3769
3777
|
this.uploadData = i, this.progress = c;
|
|
3770
3778
|
}
|
|
3771
3779
|
getProgress(e, t) {
|
|
3772
3780
|
if (this.incCounter(e, t), this.failed)
|
|
3773
3781
|
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3774
|
-
return
|
|
3782
|
+
return on(this.progress);
|
|
3775
3783
|
}
|
|
3776
3784
|
shouldScheduleUpload() {
|
|
3777
|
-
return
|
|
3785
|
+
return rn(this.progress);
|
|
3778
3786
|
}
|
|
3779
3787
|
/** Uploads a blob if it's not BlobIndex. */
|
|
3780
3788
|
async uploadBlobTask() {
|
|
3781
3789
|
try {
|
|
3782
|
-
await
|
|
3790
|
+
await en(
|
|
3783
3791
|
this.logger,
|
|
3784
3792
|
this.clientBlob,
|
|
3785
3793
|
this.res,
|
|
@@ -3791,24 +3799,24 @@ class Zo {
|
|
|
3791
3799
|
currentSpeed: this.nMaxUploads,
|
|
3792
3800
|
maxSpeed: this.maxNConcurrentPartsUpload
|
|
3793
3801
|
}
|
|
3794
|
-
), this.change.markChanged(`blob upload for ${
|
|
3802
|
+
), this.change.markChanged(`blob upload for ${U(this.res.id)} finished`);
|
|
3795
3803
|
} catch (e) {
|
|
3796
3804
|
if (this.setRetriableError(e), Ee(e)) {
|
|
3797
|
-
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${
|
|
3805
|
+
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${U(this.res.id)} aborted, resource was deleted`), this.setDone(!0);
|
|
3798
3806
|
return;
|
|
3799
3807
|
}
|
|
3800
|
-
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${
|
|
3808
|
+
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${U(this.res.id)} failed`), gt(e)) {
|
|
3801
3809
|
this.setTerminalError(e);
|
|
3802
3810
|
return;
|
|
3803
3811
|
}
|
|
3804
|
-
throw
|
|
3812
|
+
throw cn(e) && (this.nMaxUploads = dn(this.logger, this.nMaxUploads, 1)), e;
|
|
3805
3813
|
}
|
|
3806
3814
|
}
|
|
3807
3815
|
async updateStatus() {
|
|
3808
3816
|
var e;
|
|
3809
3817
|
try {
|
|
3810
|
-
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), r = this.progress.status, o =
|
|
3811
|
-
this.progress.status = o, this.setDone(t.done), (t.done || this.progress.status.progress != (r == null ? void 0 : r.progress)) && this.change.markChanged(`upload status for ${
|
|
3818
|
+
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), r = this.progress.status, o = ln(this.alreadyExisted, an(t));
|
|
3819
|
+
this.progress.status = o, this.setDone(t.done), (t.done || this.progress.status.progress != (r == null ? void 0 : r.progress)) && this.change.markChanged(`upload status for ${U(this.res.id)} changed`);
|
|
3812
3820
|
} catch (t) {
|
|
3813
3821
|
if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
|
|
3814
3822
|
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
@@ -3817,7 +3825,7 @@ class Zo {
|
|
|
3817
3825
|
if (Ee(t)) {
|
|
3818
3826
|
this.logger.warn(
|
|
3819
3827
|
`resource was not found while updating a status of BlobImport: ${t}, ${m(this.res)}`
|
|
3820
|
-
), this.change.markChanged(`upload status for ${
|
|
3828
|
+
), this.change.markChanged(`upload status for ${U(this.res.id)} changed, resource not found`), this.setDone(!0);
|
|
3821
3829
|
return;
|
|
3822
3830
|
}
|
|
3823
3831
|
this.logger.error(`retryable error while updating a status of BlobImport: ${t}`);
|
|
@@ -3832,7 +3840,7 @@ class Zo {
|
|
|
3832
3840
|
this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
|
|
3833
3841
|
}
|
|
3834
3842
|
setDoneIfOutputSet(e) {
|
|
3835
|
-
|
|
3843
|
+
nn(e) && (this.setDone(!0), this.alreadyExisted = !0);
|
|
3836
3844
|
}
|
|
3837
3845
|
setDone(e) {
|
|
3838
3846
|
this.progress.done = e, e && (this.progress.lastError = void 0);
|
|
@@ -3847,8 +3855,8 @@ class Zo {
|
|
|
3847
3855
|
return this.counter.isZero();
|
|
3848
3856
|
}
|
|
3849
3857
|
}
|
|
3850
|
-
async function
|
|
3851
|
-
|
|
3858
|
+
async function en(s, e, t, r, o, n) {
|
|
3859
|
+
Ot(be(t), "the upload operation can be done only for BlobUploads");
|
|
3852
3860
|
const l = 1e4;
|
|
3853
3861
|
if (o()) return;
|
|
3854
3862
|
const i = await e.initUpload(t, { timeout: l });
|
|
@@ -3862,13 +3870,13 @@ async function Qo(s, e, t, r, o, n) {
|
|
|
3862
3870
|
BigInt(r.modificationTime),
|
|
3863
3871
|
a,
|
|
3864
3872
|
{ timeout: l }
|
|
3865
|
-
), s.info(`uploaded chunk ${a}/${i.overall} of resource: ${t.id}`), n.nPartsWithThisUploadSpeed++, n.nPartsWithThisUploadSpeed >= n.nPartsToIncreaseUpload && (n.nPartsWithThisUploadSpeed = 0, n.currentSpeed =
|
|
3873
|
+
), s.info(`uploaded chunk ${a}/${i.overall} of resource: ${t.id}`), n.nPartsWithThisUploadSpeed++, n.nPartsWithThisUploadSpeed >= n.nPartsToIncreaseUpload && (n.nPartsWithThisUploadSpeed = 0, n.currentSpeed = hn(s, n.currentSpeed, n.maxSpeed), d.setConcurrency(n.currentSpeed)));
|
|
3866
3874
|
};
|
|
3867
3875
|
await Le(n.currentSpeed, i.toUpload.map(c)), !o() && (await e.finalize(t, { timeout: l }), s.info(`uploading of resource ${t.id} finished.`));
|
|
3868
3876
|
}
|
|
3869
|
-
function
|
|
3877
|
+
function tn(s, e) {
|
|
3870
3878
|
let t, r;
|
|
3871
|
-
return be(s) && (r = Y.parse(s.data), t =
|
|
3879
|
+
return be(s) && (r = Y.parse(s.data), t = sn(e, r.localPath, r.pathSignature)), {
|
|
3872
3880
|
uploadData: r,
|
|
3873
3881
|
progress: {
|
|
3874
3882
|
done: !1,
|
|
@@ -3879,33 +3887,33 @@ function Ko(s, e) {
|
|
|
3879
3887
|
}
|
|
3880
3888
|
};
|
|
3881
3889
|
}
|
|
3882
|
-
function
|
|
3890
|
+
function rn(s) {
|
|
3883
3891
|
return s.isUpload && (s.isUploadSignMatch ?? !1);
|
|
3884
3892
|
}
|
|
3885
|
-
function
|
|
3893
|
+
function on(s) {
|
|
3886
3894
|
return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
|
|
3887
3895
|
}
|
|
3888
|
-
function
|
|
3896
|
+
function nn(s) {
|
|
3889
3897
|
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
3890
3898
|
}
|
|
3891
3899
|
function be(s) {
|
|
3892
3900
|
return s.type.name.startsWith("BlobUpload");
|
|
3893
3901
|
}
|
|
3894
|
-
function
|
|
3902
|
+
function sn(s, e, t) {
|
|
3895
3903
|
try {
|
|
3896
3904
|
return s.verify(e, t), !0;
|
|
3897
3905
|
} catch {
|
|
3898
3906
|
return !1;
|
|
3899
3907
|
}
|
|
3900
3908
|
}
|
|
3901
|
-
function
|
|
3909
|
+
function an(s) {
|
|
3902
3910
|
return {
|
|
3903
3911
|
progress: s.progress ?? 0,
|
|
3904
3912
|
bytesProcessed: Number(s.bytesProcessed),
|
|
3905
3913
|
bytesTotal: Number(s.bytesTotal)
|
|
3906
3914
|
};
|
|
3907
3915
|
}
|
|
3908
|
-
function
|
|
3916
|
+
function ln(s, e) {
|
|
3909
3917
|
return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
|
|
3910
3918
|
progress: 1,
|
|
3911
3919
|
bytesProcessed: Number(e.bytesTotal),
|
|
@@ -3915,25 +3923,25 @@ function on(s, e) {
|
|
|
3915
3923
|
function Ee(s) {
|
|
3916
3924
|
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
3917
3925
|
}
|
|
3918
|
-
function
|
|
3926
|
+
function gt(s) {
|
|
3919
3927
|
return s instanceof Ze || s instanceof Qe || s instanceof Xe;
|
|
3920
3928
|
}
|
|
3921
|
-
function
|
|
3929
|
+
function cn(s) {
|
|
3922
3930
|
return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
|
|
3923
3931
|
}
|
|
3924
|
-
function
|
|
3932
|
+
function hn(s, e, t) {
|
|
3925
3933
|
const r = Math.min(e + 2, t);
|
|
3926
3934
|
return r != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${r}`), r;
|
|
3927
3935
|
}
|
|
3928
|
-
function
|
|
3936
|
+
function dn(s, e, t) {
|
|
3929
3937
|
const r = Math.max(Math.round(e / 2), t);
|
|
3930
3938
|
return r != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${r}`), r;
|
|
3931
3939
|
}
|
|
3932
|
-
function
|
|
3940
|
+
function un(s, e) {
|
|
3933
3941
|
const t = W(s) ? e.accessor(s).node() : Ge(s) ? s.node() : s;
|
|
3934
|
-
return t.resourceType.name.startsWith("BlobUpload") ? G(t,
|
|
3942
|
+
return t.resourceType.name.startsWith("BlobUpload") ? G(t, bo) : G(t, ko);
|
|
3935
3943
|
}
|
|
3936
|
-
class
|
|
3944
|
+
class ss {
|
|
3937
3945
|
constructor(e, t, r, o, n = {
|
|
3938
3946
|
nConcurrentPartUploads: 10,
|
|
3939
3947
|
nConcurrentGetProgresses: 10,
|
|
@@ -3965,15 +3973,15 @@ class ts {
|
|
|
3965
3973
|
}
|
|
3966
3974
|
getProgressId(e, t) {
|
|
3967
3975
|
if (t == null) return y.make((l) => this.getProgressId(e, l));
|
|
3968
|
-
const r = W(e) ?
|
|
3976
|
+
const r = W(e) ? un(e, t) : e, o = N();
|
|
3969
3977
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(r.id, o)), this.getProgressIdNoCtx(t.watcher, r, o);
|
|
3970
3978
|
}
|
|
3971
3979
|
getProgressIdNoCtx(e, t, r) {
|
|
3972
|
-
|
|
3980
|
+
gn("getProgressId", t.type);
|
|
3973
3981
|
const o = this.idToProgress.get(t.id);
|
|
3974
3982
|
if (o != null)
|
|
3975
3983
|
return o.setDoneIfOutputSet(t), o.getProgress(e, r);
|
|
3976
|
-
const n = new
|
|
3984
|
+
const n = new Yo(
|
|
3977
3985
|
this.logger,
|
|
3978
3986
|
this.clientBlob,
|
|
3979
3987
|
this.clientProgress,
|
|
@@ -3983,7 +3991,7 @@ class ts {
|
|
|
3983
3991
|
);
|
|
3984
3992
|
return this.idToProgress.set(t.id, n), n.shouldScheduleUpload() && this.uploadQueue.push({
|
|
3985
3993
|
fn: () => n.uploadBlobTask(),
|
|
3986
|
-
recoverableErrorPredicate: (l) => !
|
|
3994
|
+
recoverableErrorPredicate: (l) => !gt(l)
|
|
3987
3995
|
}), n.setDoneIfOutputSet(t), n.getProgress(e, r);
|
|
3988
3996
|
}
|
|
3989
3997
|
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
@@ -4025,20 +4033,20 @@ class ts {
|
|
|
4025
4033
|
this.currentLoop = void 0;
|
|
4026
4034
|
}
|
|
4027
4035
|
getAllNotDoneProgresses() {
|
|
4028
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !
|
|
4036
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !pn(t.progress)).map(([e, t]) => t);
|
|
4029
4037
|
}
|
|
4030
4038
|
}
|
|
4031
|
-
function
|
|
4039
|
+
function pn(s) {
|
|
4032
4040
|
var e;
|
|
4033
4041
|
return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
|
|
4034
4042
|
}
|
|
4035
|
-
function
|
|
4043
|
+
function gn(s, e) {
|
|
4036
4044
|
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
4037
4045
|
throw new $e(
|
|
4038
4046
|
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
4039
4047
|
);
|
|
4040
4048
|
}
|
|
4041
|
-
class
|
|
4049
|
+
class is {
|
|
4042
4050
|
constructor(e, t, r = {
|
|
4043
4051
|
nConcurrentGetLogs: 10,
|
|
4044
4052
|
pollingInterval: 1e3,
|
|
@@ -4108,7 +4116,7 @@ class rs {
|
|
|
4108
4116
|
getLogHandle(e, t) {
|
|
4109
4117
|
if (t == null) return y.make((n) => this.getLogHandle(e, n));
|
|
4110
4118
|
const r = S(e, t), o = this.getLogHandleNoCtx(r);
|
|
4111
|
-
return t.markUnstable(`live_log:${
|
|
4119
|
+
return t.markUnstable(`live_log:${U(r.id)}`), o;
|
|
4112
4120
|
}
|
|
4113
4121
|
getLogHandleNoCtx(e) {
|
|
4114
4122
|
return ue("getLogHandle", e.type), nt(!0, e);
|
|
@@ -4224,7 +4232,7 @@ class Fe {
|
|
|
4224
4232
|
0n,
|
|
4225
4233
|
this.patternToSearch
|
|
4226
4234
|
), t = new TextDecoder().decode(e.data);
|
|
4227
|
-
this.logs != t && this.change.markChanged(`logs for ${
|
|
4235
|
+
this.logs != t && this.change.markChanged(`logs for ${U(this.rInfo.id)} updated`), this.logs = t, this.error = void 0;
|
|
4228
4236
|
return;
|
|
4229
4237
|
} catch (e) {
|
|
4230
4238
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
@@ -4243,7 +4251,7 @@ function ue(s, e) {
|
|
|
4243
4251
|
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4244
4252
|
);
|
|
4245
4253
|
}
|
|
4246
|
-
class
|
|
4254
|
+
class as {
|
|
4247
4255
|
constructor(e, t, r) {
|
|
4248
4256
|
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = r;
|
|
4249
4257
|
}
|
|
@@ -4333,98 +4341,15 @@ function H(s, e) {
|
|
|
4333
4341
|
var t;
|
|
4334
4342
|
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4335
4343
|
}
|
|
4336
|
-
class
|
|
4337
|
-
constructor(e, t, r, o
|
|
4338
|
-
cacheSoftSizeBytes: 1 * 1024 * 1024 * 1024,
|
|
4339
|
-
// 1 GB
|
|
4340
|
-
withGunzip: !0,
|
|
4341
|
-
nConcurrentDownloads: 50
|
|
4342
|
-
}) {
|
|
4343
|
-
h(this, "downloadHelper");
|
|
4344
|
-
h(this, "urlToDownload", /* @__PURE__ */ new Map());
|
|
4345
|
-
h(this, "downloadQueue");
|
|
4346
|
-
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4347
|
-
* file that should be kept. */
|
|
4348
|
-
h(this, "cache");
|
|
4349
|
-
this.logger = e, this.saveDir = r, this.opts = o, this.downloadQueue = new Q(this.logger, this.opts.nConcurrentDownloads), this.cache = new De(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ye(t);
|
|
4350
|
-
}
|
|
4351
|
-
getPath(e, t) {
|
|
4352
|
-
if (t === void 0) return y.make((n) => this.getPath(e, n));
|
|
4353
|
-
const r = N();
|
|
4354
|
-
t.addOnDestroy(() => this.releasePath(e, r));
|
|
4355
|
-
const o = this.getPathNoCtx(e, t.watcher, r);
|
|
4356
|
-
return (o == null ? void 0 : o.path) === void 0 && t.markUnstable(
|
|
4357
|
-
`a path to the downloaded and untared archive might be undefined. The current result: ${o}`
|
|
4358
|
-
), o;
|
|
4359
|
-
}
|
|
4360
|
-
getPathNoCtx(e, t, r) {
|
|
4361
|
-
const o = e.toString(), n = this.urlToDownload.get(o);
|
|
4362
|
-
if (n != null)
|
|
4363
|
-
return n.attach(t, r), n.getPath();
|
|
4364
|
-
const l = this.setNewTask(t, e, r);
|
|
4365
|
-
return this.downloadQueue.push({
|
|
4366
|
-
fn: async () => this.downloadUrl(l, r),
|
|
4367
|
-
recoverableErrorPredicate: (i) => !0
|
|
4368
|
-
}), l.getPath();
|
|
4369
|
-
}
|
|
4370
|
-
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4371
|
-
async downloadUrl(e, t) {
|
|
4372
|
-
var r;
|
|
4373
|
-
await e.download(this.downloadHelper, this.opts.withGunzip), ((r = e.getPath()) == null ? void 0 : r.path) != null && this.cache.addCache(e, t);
|
|
4374
|
-
}
|
|
4375
|
-
/** Removes a directory and aborts a downloading task when all callers
|
|
4376
|
-
* are not interested in it. */
|
|
4377
|
-
async releasePath(e, t) {
|
|
4378
|
-
const r = e.toString(), o = this.urlToDownload.get(r);
|
|
4379
|
-
if (o != null)
|
|
4380
|
-
if (this.cache.existsFile(o.path)) {
|
|
4381
|
-
const n = this.cache.removeFile(o.path, t);
|
|
4382
|
-
await Promise.all(
|
|
4383
|
-
n.map(async (l) => {
|
|
4384
|
-
await ke(l.path), this.cache.removeCache(l), this.removeTask(
|
|
4385
|
-
l,
|
|
4386
|
-
`the task ${m(l.info())} was removedfrom cache along with ${m(n.map((i) => i.info()))}`
|
|
4387
|
-
);
|
|
4388
|
-
})
|
|
4389
|
-
);
|
|
4390
|
-
} else
|
|
4391
|
-
o.counter.dec(t) && this.removeTask(
|
|
4392
|
-
o,
|
|
4393
|
-
`the task ${m(o.info())} was removed from cache`
|
|
4394
|
-
);
|
|
4395
|
-
}
|
|
4396
|
-
/** Removes all files from a hard drive. */
|
|
4397
|
-
async releaseAll() {
|
|
4398
|
-
this.downloadQueue.stop(), await Promise.all(
|
|
4399
|
-
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4400
|
-
await ke(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4401
|
-
t,
|
|
4402
|
-
`the task ${m(t.info())} was released when the driver was closed`
|
|
4403
|
-
);
|
|
4404
|
-
})
|
|
4405
|
-
);
|
|
4406
|
-
}
|
|
4407
|
-
setNewTask(e, t, r) {
|
|
4408
|
-
const o = new dn(this.logger, this.getFilePath(t), t);
|
|
4409
|
-
return o.attach(e, r), this.urlToDownload.set(t.toString(), o), o;
|
|
4410
|
-
}
|
|
4411
|
-
removeTask(e, t) {
|
|
4412
|
-
e.abort(t), e.change.markChanged(`task for url ${e.url} removed: ${t}`), this.urlToDownload.delete(e.url.toString());
|
|
4413
|
-
}
|
|
4414
|
-
getFilePath(e) {
|
|
4415
|
-
const t = Dt("sha256").update(e.toString()).digest("hex");
|
|
4416
|
-
return k.join(this.saveDir, t);
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
class dn {
|
|
4420
|
-
constructor(e, t, r) {
|
|
4344
|
+
class fn {
|
|
4345
|
+
constructor(e, t, r, o, n) {
|
|
4421
4346
|
h(this, "counter", new v());
|
|
4422
4347
|
h(this, "change", new B());
|
|
4423
4348
|
h(this, "signalCtl", new AbortController());
|
|
4424
4349
|
h(this, "error");
|
|
4425
4350
|
h(this, "done", !1);
|
|
4426
4351
|
h(this, "size", 0);
|
|
4427
|
-
this.logger = e, this.path = t, this.url = r;
|
|
4352
|
+
this.logger = e, this.path = t, this.url = r, this.signer = o, this.saveDir = n;
|
|
4428
4353
|
}
|
|
4429
4354
|
info() {
|
|
4430
4355
|
return {
|
|
@@ -4452,7 +4377,7 @@ class dn {
|
|
|
4452
4377
|
}
|
|
4453
4378
|
async downloadAndUntar(e, t, r) {
|
|
4454
4379
|
if (await F(k.dirname(this.path)), await z(this.path))
|
|
4455
|
-
return await
|
|
4380
|
+
return await ft(this.path);
|
|
4456
4381
|
const o = await e.download(this.url.toString(), {}, r);
|
|
4457
4382
|
let n = o.content;
|
|
4458
4383
|
if (t) {
|
|
@@ -4461,12 +4386,14 @@ class dn {
|
|
|
4461
4386
|
}
|
|
4462
4387
|
return await Z(this.logger, this.path, async (l) => {
|
|
4463
4388
|
await w.mkdir(l);
|
|
4464
|
-
const i =
|
|
4389
|
+
const i = I.toWeb(me.extract(l));
|
|
4465
4390
|
await n.pipeTo(i, { signal: r });
|
|
4466
4391
|
}), o.size;
|
|
4467
4392
|
}
|
|
4468
|
-
|
|
4469
|
-
if (this.done) return {
|
|
4393
|
+
getUrl() {
|
|
4394
|
+
if (this.done) return {
|
|
4395
|
+
url: qo(this.signer, this.saveDir, J(this.path))
|
|
4396
|
+
};
|
|
4470
4397
|
if (this.error) return { error: this.error };
|
|
4471
4398
|
}
|
|
4472
4399
|
setDone(e) {
|
|
@@ -4485,25 +4412,120 @@ class Oe extends Error {
|
|
|
4485
4412
|
h(this, "name", "URLAborted");
|
|
4486
4413
|
}
|
|
4487
4414
|
}
|
|
4488
|
-
async function
|
|
4415
|
+
async function ft(s) {
|
|
4489
4416
|
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
4490
4417
|
return (await Promise.all(
|
|
4491
4418
|
e.map(async (r) => {
|
|
4492
4419
|
const o = k.join(s, r.name);
|
|
4493
|
-
return r.isDirectory() ? await
|
|
4420
|
+
return r.isDirectory() ? await ft(o) : (await w.stat(o)).size;
|
|
4494
4421
|
})
|
|
4495
4422
|
)).reduce((r, o) => r + o, 0);
|
|
4496
4423
|
}
|
|
4497
4424
|
async function ke(s) {
|
|
4498
4425
|
await w.rm(s, { recursive: !0, force: !0 });
|
|
4499
4426
|
}
|
|
4427
|
+
class ls {
|
|
4428
|
+
constructor(e, t, r, o, n = {
|
|
4429
|
+
cacheSoftSizeBytes: 1 * 1024 * 1024 * 1024,
|
|
4430
|
+
// 1 GB
|
|
4431
|
+
withGunzip: !0,
|
|
4432
|
+
nConcurrentDownloads: 50
|
|
4433
|
+
}) {
|
|
4434
|
+
h(this, "downloadHelper");
|
|
4435
|
+
h(this, "urlToDownload", /* @__PURE__ */ new Map());
|
|
4436
|
+
h(this, "downloadQueue");
|
|
4437
|
+
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4438
|
+
* file that should be kept. */
|
|
4439
|
+
h(this, "cache");
|
|
4440
|
+
this.logger = e, this.saveDir = r, this.signer = o, this.opts = n, this.downloadQueue = new Q(this.logger, this.opts.nConcurrentDownloads), this.cache = new Ie(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ye(t);
|
|
4441
|
+
}
|
|
4442
|
+
/** Returns a computable that returns a custom protocol URL to the downloaded and unarchived path. */
|
|
4443
|
+
getUrl(e, t) {
|
|
4444
|
+
if (t === void 0) return y.make((n) => this.getUrl(e, n));
|
|
4445
|
+
const r = N();
|
|
4446
|
+
t.addOnDestroy(() => this.releasePath(e, r));
|
|
4447
|
+
const o = this.getUrlNoCtx(e, t.watcher, r);
|
|
4448
|
+
return (o == null ? void 0 : o.url) === void 0 && t.markUnstable(
|
|
4449
|
+
`a path to the downloaded and untared archive might be undefined. The current result: ${o}`
|
|
4450
|
+
), o;
|
|
4451
|
+
}
|
|
4452
|
+
getUrlNoCtx(e, t, r) {
|
|
4453
|
+
const o = e.toString(), n = this.urlToDownload.get(o);
|
|
4454
|
+
if (n !== void 0)
|
|
4455
|
+
return n.attach(t, r), n.getUrl();
|
|
4456
|
+
const l = this.setNewTask(t, e, r);
|
|
4457
|
+
return this.downloadQueue.push({
|
|
4458
|
+
fn: async () => this.downloadUrl(l, r),
|
|
4459
|
+
recoverableErrorPredicate: (i) => !0
|
|
4460
|
+
}), l.getUrl();
|
|
4461
|
+
}
|
|
4462
|
+
getPathForBlockUI(e) {
|
|
4463
|
+
if (!It(e))
|
|
4464
|
+
throw new Error(`getPathForBlockUI: ${e} is invalid`);
|
|
4465
|
+
return Zo(this.signer, e, this.saveDir);
|
|
4466
|
+
}
|
|
4467
|
+
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4468
|
+
async downloadUrl(e, t) {
|
|
4469
|
+
var r;
|
|
4470
|
+
await e.download(this.downloadHelper, this.opts.withGunzip), ((r = e.getUrl()) == null ? void 0 : r.url) !== void 0 && this.cache.addCache(e, t);
|
|
4471
|
+
}
|
|
4472
|
+
/** Removes a directory and aborts a downloading task when all callers
|
|
4473
|
+
* are not interested in it. */
|
|
4474
|
+
async releasePath(e, t) {
|
|
4475
|
+
const r = e.toString(), o = this.urlToDownload.get(r);
|
|
4476
|
+
if (o != null)
|
|
4477
|
+
if (this.cache.existsFile(o.path)) {
|
|
4478
|
+
const n = this.cache.removeFile(o.path, t);
|
|
4479
|
+
await Promise.all(
|
|
4480
|
+
n.map(async (l) => {
|
|
4481
|
+
await ke(l.path), this.cache.removeCache(l), this.removeTask(
|
|
4482
|
+
l,
|
|
4483
|
+
`the task ${m(l.info())} was removedfrom cache along with ${m(n.map((i) => i.info()))}`
|
|
4484
|
+
);
|
|
4485
|
+
})
|
|
4486
|
+
);
|
|
4487
|
+
} else
|
|
4488
|
+
o.counter.dec(t) && this.removeTask(
|
|
4489
|
+
o,
|
|
4490
|
+
`the task ${m(o.info())} was removed from cache`
|
|
4491
|
+
);
|
|
4492
|
+
}
|
|
4493
|
+
/** Removes all files from a hard drive. */
|
|
4494
|
+
async releaseAll() {
|
|
4495
|
+
this.downloadQueue.stop(), await Promise.all(
|
|
4496
|
+
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4497
|
+
await ke(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4498
|
+
t,
|
|
4499
|
+
`the task ${m(t.info())} was released when the driver was closed`
|
|
4500
|
+
);
|
|
4501
|
+
})
|
|
4502
|
+
);
|
|
4503
|
+
}
|
|
4504
|
+
setNewTask(e, t, r) {
|
|
4505
|
+
const o = new fn(
|
|
4506
|
+
this.logger,
|
|
4507
|
+
this.getFilePath(t),
|
|
4508
|
+
t,
|
|
4509
|
+
this.signer,
|
|
4510
|
+
this.saveDir
|
|
4511
|
+
);
|
|
4512
|
+
return o.attach(e, r), this.urlToDownload.set(t.toString(), o), o;
|
|
4513
|
+
}
|
|
4514
|
+
removeTask(e, t) {
|
|
4515
|
+
e.abort(t), e.change.markChanged(`task for url ${e.url} removed: ${t}`), this.urlToDownload.delete(e.url.toString());
|
|
4516
|
+
}
|
|
4517
|
+
getFilePath(e) {
|
|
4518
|
+
const t = Bt("sha256").update(e.toString()).digest("hex");
|
|
4519
|
+
return k.join(this.saveDir, t);
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4500
4522
|
function pe(s, e) {
|
|
4501
4523
|
return `index://index/${encodeURIComponent(JSON.stringify({
|
|
4502
4524
|
storageId: s,
|
|
4503
4525
|
path: e
|
|
4504
4526
|
}))}`;
|
|
4505
4527
|
}
|
|
4506
|
-
function
|
|
4528
|
+
function wn(s, e, t, r) {
|
|
4507
4529
|
const o = {
|
|
4508
4530
|
localPath: s,
|
|
4509
4531
|
pathSignature: e.sign(s),
|
|
@@ -4512,32 +4534,32 @@ function un(s, e, t, r) {
|
|
|
4512
4534
|
};
|
|
4513
4535
|
return `upload://upload/${encodeURIComponent(JSON.stringify(o))}`;
|
|
4514
4536
|
}
|
|
4515
|
-
function
|
|
4537
|
+
function mn(s) {
|
|
4516
4538
|
const e = new URL(s);
|
|
4517
4539
|
return Y.parse(
|
|
4518
4540
|
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4519
4541
|
);
|
|
4520
4542
|
}
|
|
4521
|
-
function
|
|
4543
|
+
function yn(s) {
|
|
4522
4544
|
const e = new URL(s);
|
|
4523
4545
|
return rt.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4524
4546
|
}
|
|
4525
4547
|
function ze(s) {
|
|
4526
|
-
if (
|
|
4527
|
-
return
|
|
4528
|
-
if (
|
|
4529
|
-
return
|
|
4530
|
-
|
|
4531
|
-
}
|
|
4532
|
-
const
|
|
4533
|
-
function
|
|
4534
|
-
return
|
|
4548
|
+
if (Ln(s))
|
|
4549
|
+
return Pn(s);
|
|
4550
|
+
if (bn(s))
|
|
4551
|
+
return Tn(s);
|
|
4552
|
+
Rt(s);
|
|
4553
|
+
}
|
|
4554
|
+
const wt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4555
|
+
function bn(s) {
|
|
4556
|
+
return wt.test(s);
|
|
4535
4557
|
}
|
|
4536
|
-
function
|
|
4558
|
+
function kn(s, e) {
|
|
4537
4559
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4538
4560
|
}
|
|
4539
|
-
function
|
|
4540
|
-
const e = s.match(
|
|
4561
|
+
function Tn(s) {
|
|
4562
|
+
const e = s.match(wt);
|
|
4541
4563
|
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4542
4564
|
const { name: t, path: r } = e.groups;
|
|
4543
4565
|
return {
|
|
@@ -4546,30 +4568,30 @@ function mn(s) {
|
|
|
4546
4568
|
isRemote: !1
|
|
4547
4569
|
};
|
|
4548
4570
|
}
|
|
4549
|
-
const
|
|
4550
|
-
function
|
|
4551
|
-
return
|
|
4571
|
+
const mt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4572
|
+
function Ln(s) {
|
|
4573
|
+
return mt.test(s);
|
|
4552
4574
|
}
|
|
4553
|
-
function
|
|
4575
|
+
function Un(s, e) {
|
|
4554
4576
|
return `remote://${s}/${BigInt(e)}`;
|
|
4555
4577
|
}
|
|
4556
|
-
function
|
|
4557
|
-
const e = s.match(
|
|
4578
|
+
function Pn(s) {
|
|
4579
|
+
const e = s.match(mt);
|
|
4558
4580
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4559
4581
|
const { name: t, resourceId: r } = e.groups;
|
|
4560
4582
|
return {
|
|
4561
4583
|
id: Te(BigInt(r)),
|
|
4562
|
-
type:
|
|
4584
|
+
type: Rn(t),
|
|
4563
4585
|
name: t,
|
|
4564
4586
|
isRemote: !0
|
|
4565
4587
|
};
|
|
4566
4588
|
}
|
|
4567
|
-
function
|
|
4589
|
+
function Rn(s) {
|
|
4568
4590
|
return { name: `LS/${s}`, version: "1" };
|
|
4569
4591
|
}
|
|
4570
|
-
async function
|
|
4571
|
-
const s =
|
|
4572
|
-
if (
|
|
4592
|
+
async function Nn() {
|
|
4593
|
+
const s = Ct.homedir();
|
|
4594
|
+
if (L.sep == "/")
|
|
4573
4595
|
return [
|
|
4574
4596
|
{
|
|
4575
4597
|
name: "local",
|
|
@@ -4578,9 +4600,9 @@ async function Ln() {
|
|
|
4578
4600
|
}
|
|
4579
4601
|
];
|
|
4580
4602
|
{
|
|
4581
|
-
const t =
|
|
4603
|
+
const t = L.parse(s).root.replaceAll(":\\", "");
|
|
4582
4604
|
try {
|
|
4583
|
-
return (await
|
|
4605
|
+
return (await zt.promisify(Wt)("wmic logicaldisk get name")).stdout.split(`\r
|
|
4584
4606
|
`).filter((n) => n.includes(":")).map((n) => n.trim().replaceAll(":", "")).map((n) => {
|
|
4585
4607
|
const l = n == t;
|
|
4586
4608
|
return {
|
|
@@ -4600,7 +4622,7 @@ async function Ln() {
|
|
|
4600
4622
|
}
|
|
4601
4623
|
}
|
|
4602
4624
|
}
|
|
4603
|
-
class
|
|
4625
|
+
class yt {
|
|
4604
4626
|
constructor(e, t, r, o, n, l, i) {
|
|
4605
4627
|
this.logger = e, this.lsClient = t, this.storageIdToResourceId = r, this.signer = o, this.virtualStoragesMap = n, this.localProjectionsMap = l, this.openFileDialogCallback = i;
|
|
4606
4628
|
}
|
|
@@ -4632,13 +4654,13 @@ class mt {
|
|
|
4632
4654
|
* @private
|
|
4633
4655
|
*/
|
|
4634
4656
|
async tryResolveLocalFileHandle(e) {
|
|
4635
|
-
if (
|
|
4636
|
-
const t =
|
|
4657
|
+
if (Dt(e)) {
|
|
4658
|
+
const t = yn(e), r = this.localProjectionsMap.get(t.storageId);
|
|
4637
4659
|
if (!r)
|
|
4638
4660
|
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4639
4661
|
return k.join(r.localPath, t.path);
|
|
4640
4662
|
} else {
|
|
4641
|
-
const t =
|
|
4663
|
+
const t = mn(e);
|
|
4642
4664
|
this.signer.verify(
|
|
4643
4665
|
t.localPath,
|
|
4644
4666
|
t.pathSignature,
|
|
@@ -4661,7 +4683,7 @@ class mt {
|
|
|
4661
4683
|
);
|
|
4662
4684
|
}
|
|
4663
4685
|
const t = await w.stat(e, { bigint: !0 });
|
|
4664
|
-
return
|
|
4686
|
+
return wn(
|
|
4665
4687
|
e,
|
|
4666
4688
|
this.signer,
|
|
4667
4689
|
t.size,
|
|
@@ -4672,12 +4694,12 @@ class mt {
|
|
|
4672
4694
|
async getStorageList() {
|
|
4673
4695
|
const e = [...this.virtualStoragesMap.values()].map((o) => ({
|
|
4674
4696
|
name: o.name,
|
|
4675
|
-
handle:
|
|
4697
|
+
handle: kn(o.name, o.root),
|
|
4676
4698
|
initialFullPath: o.initialPath
|
|
4677
4699
|
})), r = Object.entries(this.storageIdToResourceId).map(
|
|
4678
4700
|
([o, n]) => ({
|
|
4679
4701
|
name: o,
|
|
4680
|
-
handle:
|
|
4702
|
+
handle: Un(o, n),
|
|
4681
4703
|
initialFullPath: "",
|
|
4682
4704
|
// we don't have any additional information from where to start browsing remote storages
|
|
4683
4705
|
isInitialPathHome: !1
|
|
@@ -4730,8 +4752,8 @@ class mt {
|
|
|
4730
4752
|
);
|
|
4731
4753
|
}
|
|
4732
4754
|
static async init(e, t, r, o, n, l) {
|
|
4733
|
-
const i =
|
|
4734
|
-
l || (l = await
|
|
4755
|
+
const i = fo(t, e);
|
|
4756
|
+
l || (l = await Nn());
|
|
4735
4757
|
for (const d of l) E(d.root);
|
|
4736
4758
|
for (const d of o) d.localPath !== "" && E(d.localPath);
|
|
4737
4759
|
const c = new Map(l.map((d) => [d.name, d])), a = new Map(o.map((d) => [d.storageId, d]));
|
|
@@ -4739,10 +4761,10 @@ class mt {
|
|
|
4739
4761
|
throw new Error(
|
|
4740
4762
|
"Intersection between local projection storage ids and virtual storages names detected."
|
|
4741
4763
|
);
|
|
4742
|
-
return new
|
|
4764
|
+
return new yt(
|
|
4743
4765
|
e,
|
|
4744
4766
|
i,
|
|
4745
|
-
await
|
|
4767
|
+
await $n(t),
|
|
4746
4768
|
r,
|
|
4747
4769
|
c,
|
|
4748
4770
|
a,
|
|
@@ -4750,64 +4772,64 @@ class mt {
|
|
|
4750
4772
|
);
|
|
4751
4773
|
}
|
|
4752
4774
|
}
|
|
4753
|
-
async function
|
|
4775
|
+
async function $n(s) {
|
|
4754
4776
|
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4755
4777
|
const t = await e.getResourceByName("LSProvider"), r = await e.getResourceData(t, !0);
|
|
4756
|
-
return
|
|
4778
|
+
return Sn(r);
|
|
4757
4779
|
});
|
|
4758
4780
|
}
|
|
4759
|
-
function
|
|
4781
|
+
function Sn(s) {
|
|
4760
4782
|
return Object.fromEntries(
|
|
4761
|
-
s.fields.filter((e) => e.type == "Dynamic" &&
|
|
4783
|
+
s.fields.filter((e) => e.type == "Dynamic" && Lt(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4762
4784
|
);
|
|
4763
4785
|
}
|
|
4764
4786
|
export {
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4787
|
+
zr as ClientDownload,
|
|
4788
|
+
go as ClientLogs,
|
|
4789
|
+
Yr as ClientLs,
|
|
4790
|
+
Sr as ClientProgress,
|
|
4791
|
+
cr as ClientUpload,
|
|
4792
|
+
Nn as DefaultVirtualLocalStorages,
|
|
4793
|
+
ns as DownloadBlobToURLDriver,
|
|
4772
4794
|
ht as DownloadDriver,
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4795
|
+
ls as DownloadUrlDriver,
|
|
4796
|
+
jo as DownloadableBlobSnapshot,
|
|
4797
|
+
rs as ImportFileHandleData,
|
|
4776
4798
|
rt as ImportFileHandleIndexData,
|
|
4777
4799
|
Y as ImportFileHandleUploadData,
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4800
|
+
ko as IndexResourceSnapshot,
|
|
4801
|
+
as as LogsDriver,
|
|
4802
|
+
is as LogsStreamDriver,
|
|
4803
|
+
yt as LsDriver,
|
|
4782
4804
|
Ze as MTimeError,
|
|
4783
4805
|
Ke as NetworkError,
|
|
4784
4806
|
Xe as NoFileForUploading,
|
|
4785
|
-
|
|
4807
|
+
yo as OnDemandBlobResourceSnapshot,
|
|
4786
4808
|
Qe as UnexpectedEOF,
|
|
4787
4809
|
Ne as UnknownStorageError,
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4810
|
+
Po as Updater,
|
|
4811
|
+
ss as UploadDriver,
|
|
4812
|
+
bo as UploadResourceSnapshot,
|
|
4813
|
+
Yo as UploadTask,
|
|
4792
4814
|
Re as WrongLocalFileUrl,
|
|
4793
4815
|
$e as WrongResourceTypeError,
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4816
|
+
Xn as createDownloadClient,
|
|
4817
|
+
Yn as createLogsClient,
|
|
4818
|
+
fo as createLsFilesClient,
|
|
4819
|
+
ts as createUploadBlobClient,
|
|
4820
|
+
es as createUploadProgressClient,
|
|
4821
|
+
xr as getFullPath,
|
|
4800
4822
|
tt as getSize,
|
|
4801
|
-
|
|
4823
|
+
rn as isMyUpload,
|
|
4802
4824
|
Ee as isResourceWasDeletedError,
|
|
4803
|
-
|
|
4825
|
+
sn as isSignMatch,
|
|
4804
4826
|
be as isUpload,
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4827
|
+
un as makeBlobImportSnapshot,
|
|
4828
|
+
Go as makeDownloadableBlobSnapshot,
|
|
4829
|
+
Hr as newLocalStorageIdsToRoot,
|
|
4830
|
+
gt as nonRecoverableError,
|
|
4831
|
+
Wr as parseLocalUrl,
|
|
4832
|
+
en as uploadBlob,
|
|
4811
4833
|
E as validateAbsolute
|
|
4812
4834
|
};
|
|
4813
4835
|
//# sourceMappingURL=index.mjs.map
|