@milaboratories/pl-drivers 1.8.2 → 1.9.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/clients/upload.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +568 -551
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/clients/upload.ts +28 -3
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (s, e, t) =>
|
|
4
|
-
import { addRTypeToMetadata as
|
|
1
|
+
var Ut = Object.defineProperty;
|
|
2
|
+
var Pt = (s, e, t) => e in s ? Ut(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var h = (s, e, t) => Pt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { addRTypeToMetadata as $, stringifyWithResourceId as y, bigintToResourceId as Pe, resourceIdToString as P, isNotNullResourceId as Rt } from "@milaboratories/pl-client";
|
|
5
5
|
import * as w from "node:fs/promises";
|
|
6
6
|
import { request as Ae } from "undici";
|
|
7
|
-
import { ServiceType as
|
|
8
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as p, PbLong as I, typeofJsonValue as Me, assertNever as
|
|
9
|
-
import { notEmpty as
|
|
7
|
+
import { ServiceType as x, stackIntercept as R } from "@protobuf-ts/runtime-rpc";
|
|
8
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as p, PbLong as I, typeofJsonValue as Me, assertNever as Nt } from "@protobuf-ts/runtime";
|
|
9
|
+
import { notEmpty as K, ConcurrencyLimitingExecutor as He, CallersCounter as B, ensureDirExists as W, fileExists as A, createPathAtomically as X, mapGet as me, mapEntries as je, spawnAsync as $t, TaskProcessor as Y, asyncPool as Re, assertNever as St } from "@milaboratories/ts-helpers";
|
|
10
10
|
import * as Ne from "node:fs";
|
|
11
11
|
import ye, { promises as be } from "node:fs";
|
|
12
|
-
import * as
|
|
13
|
-
import
|
|
14
|
-
import { Readable as Ge, Writable as
|
|
15
|
-
import { text as
|
|
16
|
-
import { ChangeSource as C, Computable as
|
|
17
|
-
import { RangeBytes as
|
|
18
|
-
import { rsSchema as
|
|
19
|
-
import
|
|
20
|
-
import { randomUUID as
|
|
12
|
+
import * as T from "node:path";
|
|
13
|
+
import U from "node:path";
|
|
14
|
+
import { Readable as Ge, Writable as z, Transform as Ve } from "node:stream";
|
|
15
|
+
import { text as It, buffer as qe } from "node:stream/consumers";
|
|
16
|
+
import { ChangeSource as C, Computable as b, PollingComputableHooks as Je } from "@milaboratories/computable";
|
|
17
|
+
import { RangeBytes as Dt, validateRangeBytes as Be, isFolderURL as vt, isBlockUIURL as Bt, isImportFileHandleIndex as Ct } from "@milaboratories/pl-model-common";
|
|
18
|
+
import { rsSchema as ee, treeEntryToResourceInfo as D, isPlTreeEntry as M, makeResourceSnapshot as J, isPlTreeEntryAccessor as Ze } from "@milaboratories/pl-tree";
|
|
19
|
+
import Et from "denque";
|
|
20
|
+
import { randomUUID as S, createHash as _t } from "node:crypto";
|
|
21
21
|
import * as Ce from "node:os";
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
24
|
-
import { z as
|
|
25
|
-
import { functions as
|
|
22
|
+
import Ft from "node:os";
|
|
23
|
+
import * as Ot from "node:readline/promises";
|
|
24
|
+
import { z as L } from "zod";
|
|
25
|
+
import { functions as zt } from "@milaboratories/helpers";
|
|
26
26
|
import * as Qe from "node:zlib";
|
|
27
27
|
import * as ke from "tar-fs";
|
|
28
|
-
import
|
|
28
|
+
import Wt from "decompress";
|
|
29
29
|
import { scheduler as Ke } from "node:timers/promises";
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import { exec as
|
|
33
|
-
class
|
|
30
|
+
import xt from "node:assert";
|
|
31
|
+
import At from "node:util";
|
|
32
|
+
import { exec as Mt } from "node:child_process";
|
|
33
|
+
class Ht extends g {
|
|
34
34
|
constructor() {
|
|
35
35
|
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
36
36
|
}
|
|
@@ -58,8 +58,8 @@ class Mt extends g {
|
|
|
58
58
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
new
|
|
62
|
-
class
|
|
61
|
+
new Ht();
|
|
62
|
+
class jt extends g {
|
|
63
63
|
constructor() {
|
|
64
64
|
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
65
65
|
}
|
|
@@ -87,8 +87,8 @@ class Ht extends g {
|
|
|
87
87
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
new
|
|
91
|
-
class
|
|
90
|
+
new jt();
|
|
91
|
+
class Gt extends g {
|
|
92
92
|
constructor() {
|
|
93
93
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
94
94
|
{
|
|
@@ -130,8 +130,8 @@ class jt extends g {
|
|
|
130
130
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
class
|
|
133
|
+
const Vt = new Gt();
|
|
134
|
+
class qt extends g {
|
|
135
135
|
constructor() {
|
|
136
136
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
137
137
|
{
|
|
@@ -169,7 +169,7 @@ class Vt extends g {
|
|
|
169
169
|
case /* repeated uint64 uploaded_parts */
|
|
170
170
|
2:
|
|
171
171
|
if (l === p.LengthDelimited)
|
|
172
|
-
for (let
|
|
172
|
+
for (let N = e.int32() + e.pos; e.pos < N; )
|
|
173
173
|
o.uploadedParts.push(e.uint64().toBigInt());
|
|
174
174
|
else
|
|
175
175
|
o.uploadedParts.push(e.uint64().toBigInt());
|
|
@@ -195,8 +195,8 @@ class Vt extends g {
|
|
|
195
195
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const
|
|
199
|
-
class
|
|
198
|
+
const Jt = new qt();
|
|
199
|
+
class Zt extends g {
|
|
200
200
|
constructor() {
|
|
201
201
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
202
202
|
}
|
|
@@ -224,8 +224,8 @@ class Jt extends g {
|
|
|
224
224
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
new
|
|
228
|
-
class
|
|
227
|
+
new Zt();
|
|
228
|
+
class Qt extends g {
|
|
229
229
|
constructor() {
|
|
230
230
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
231
231
|
{
|
|
@@ -279,8 +279,8 @@ class Zt extends g {
|
|
|
279
279
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
class
|
|
282
|
+
const Kt = new Qt();
|
|
283
|
+
class Xt extends g {
|
|
284
284
|
constructor() {
|
|
285
285
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response", []);
|
|
286
286
|
}
|
|
@@ -308,8 +308,8 @@ class Kt extends g {
|
|
|
308
308
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
class
|
|
311
|
+
const Yt = new Xt();
|
|
312
|
+
class er extends g {
|
|
313
313
|
constructor() {
|
|
314
314
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
315
315
|
}
|
|
@@ -337,8 +337,8 @@ class Yt extends g {
|
|
|
337
337
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
new
|
|
341
|
-
class
|
|
340
|
+
new er();
|
|
341
|
+
class tr extends g {
|
|
342
342
|
constructor() {
|
|
343
343
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
344
344
|
{
|
|
@@ -415,8 +415,8 @@ class er extends g {
|
|
|
415
415
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
const
|
|
419
|
-
class
|
|
418
|
+
const rr = new tr();
|
|
419
|
+
class nr extends g {
|
|
420
420
|
constructor() {
|
|
421
421
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
422
422
|
{
|
|
@@ -470,8 +470,8 @@ class rr extends g {
|
|
|
470
470
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
const oe = new
|
|
474
|
-
class
|
|
473
|
+
const oe = new nr();
|
|
474
|
+
class or extends g {
|
|
475
475
|
constructor() {
|
|
476
476
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
477
477
|
{
|
|
@@ -555,8 +555,8 @@ class nr extends g {
|
|
|
555
555
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
const
|
|
559
|
-
class
|
|
558
|
+
const sr = new or();
|
|
559
|
+
class ir extends g {
|
|
560
560
|
constructor() {
|
|
561
561
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
562
562
|
}
|
|
@@ -584,8 +584,8 @@ class sr extends g {
|
|
|
584
584
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
new
|
|
588
|
-
class
|
|
587
|
+
new ir();
|
|
588
|
+
class ar extends g {
|
|
589
589
|
constructor() {
|
|
590
590
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
591
591
|
{
|
|
@@ -627,8 +627,8 @@ class ir extends g {
|
|
|
627
627
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
const
|
|
631
|
-
class
|
|
630
|
+
const lr = new ar();
|
|
631
|
+
class cr extends g {
|
|
632
632
|
constructor() {
|
|
633
633
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
634
634
|
}
|
|
@@ -656,13 +656,13 @@ class lr extends g {
|
|
|
656
656
|
return n !== !1 && (n == !0 ? u.onWrite : n)(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 hr = new cr(), se = new x("MiLaboratories.Controller.Shared.Upload", [
|
|
660
|
+
{ name: "Init", options: {}, I: Vt, O: Jt },
|
|
661
|
+
{ name: "GetPartURL", options: {}, I: rr, O: sr },
|
|
662
|
+
{ name: "UpdateProgress", options: {}, I: Kt, O: Yt },
|
|
663
|
+
{ name: "Finalize", options: {}, I: lr, O: hr }
|
|
664
664
|
]);
|
|
665
|
-
class
|
|
665
|
+
class dr {
|
|
666
666
|
constructor(e) {
|
|
667
667
|
h(this, "typeName", se.typeName);
|
|
668
668
|
h(this, "methods", se.methods);
|
|
@@ -678,7 +678,7 @@ class hr {
|
|
|
678
678
|
*/
|
|
679
679
|
init(e, t) {
|
|
680
680
|
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
681
|
-
return
|
|
681
|
+
return R("unary", this._transport, r, n, e);
|
|
682
682
|
}
|
|
683
683
|
/**
|
|
684
684
|
*
|
|
@@ -690,7 +690,7 @@ class hr {
|
|
|
690
690
|
*/
|
|
691
691
|
getPartURL(e, t) {
|
|
692
692
|
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
693
|
-
return
|
|
693
|
+
return R("unary", this._transport, r, n, e);
|
|
694
694
|
}
|
|
695
695
|
/**
|
|
696
696
|
*
|
|
@@ -701,7 +701,7 @@ class hr {
|
|
|
701
701
|
*/
|
|
702
702
|
updateProgress(e, t) {
|
|
703
703
|
const r = this.methods[2], n = this._transport.mergeOptions(t);
|
|
704
|
-
return
|
|
704
|
+
return R("unary", this._transport, r, n, e);
|
|
705
705
|
}
|
|
706
706
|
/**
|
|
707
707
|
*
|
|
@@ -714,7 +714,7 @@ class hr {
|
|
|
714
714
|
*/
|
|
715
715
|
finalize(e, t) {
|
|
716
716
|
const r = this.methods[3], n = this._transport.mergeOptions(t);
|
|
717
|
-
return
|
|
717
|
+
return R("unary", this._transport, r, n, e);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
class Xe extends Error {
|
|
@@ -741,10 +741,10 @@ class tt extends Error {
|
|
|
741
741
|
h(this, "name", "NoFileForUploading");
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
class
|
|
744
|
+
class ur {
|
|
745
745
|
constructor(e, t, r, n) {
|
|
746
746
|
h(this, "grpcClient");
|
|
747
|
-
this.httpClient = t, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new
|
|
747
|
+
this.httpClient = t, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new dr(o));
|
|
748
748
|
}
|
|
749
749
|
close() {
|
|
750
750
|
}
|
|
@@ -762,13 +762,26 @@ class dr {
|
|
|
762
762
|
0n,
|
|
763
763
|
// we update progress as a separate call later.
|
|
764
764
|
c
|
|
765
|
-
), l = await
|
|
766
|
-
await
|
|
765
|
+
), l = await pr(r, i.chunkStart, i.chunkEnd);
|
|
766
|
+
await fr(r, n);
|
|
767
|
+
const a = Number(i.chunkEnd - i.chunkStart);
|
|
768
|
+
if (l.length !== a)
|
|
769
|
+
throw new Error(
|
|
770
|
+
`Chunk size mismatch: expected ${a} bytes, but read ${l.length} bytes from file`
|
|
771
|
+
);
|
|
772
|
+
const d = Object.fromEntries(i.headers.map(({ name: m, value: E }) => [m, E])), N = Object.keys(d).find((m) => m.toLowerCase() === "content-length");
|
|
773
|
+
if (N) {
|
|
774
|
+
const m = Number(d[N]);
|
|
775
|
+
if (m !== a)
|
|
776
|
+
throw new Error(
|
|
777
|
+
`Content-Length mismatch: expected ${a}, but got ${m} in headers`
|
|
778
|
+
);
|
|
779
|
+
}
|
|
767
780
|
try {
|
|
768
781
|
const {
|
|
769
|
-
body:
|
|
770
|
-
statusCode:
|
|
771
|
-
headers:
|
|
782
|
+
body: m,
|
|
783
|
+
statusCode: E,
|
|
784
|
+
headers: ne
|
|
772
785
|
} = await Ae(i.uploadUrl, {
|
|
773
786
|
dispatcher: this.httpClient,
|
|
774
787
|
body: l,
|
|
@@ -778,12 +791,16 @@ class dr {
|
|
|
778
791
|
// that's why we got big timeout here.
|
|
779
792
|
headersTimeout: 6e4,
|
|
780
793
|
bodyTimeout: 6e4,
|
|
781
|
-
|
|
794
|
+
// Prevent connection reuse by setting "Connection: close" header.
|
|
795
|
+
// This works around an issue with the backend's built-in S3 implementation
|
|
796
|
+
// that caused HTTP/1.1 protocol lines to be included in the uploaded file content.
|
|
797
|
+
reset: !0,
|
|
798
|
+
headers: d,
|
|
782
799
|
method: i.method.toUpperCase()
|
|
783
|
-
}),
|
|
784
|
-
|
|
785
|
-
} catch (
|
|
786
|
-
throw
|
|
800
|
+
}), Lt = await m.text();
|
|
801
|
+
wr(E, Lt, ne, i);
|
|
802
|
+
} catch (m) {
|
|
803
|
+
throw m instanceof et ? m : new Error(`partUpload: error ${JSON.stringify(m)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
|
|
787
804
|
}
|
|
788
805
|
await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), c);
|
|
789
806
|
}
|
|
@@ -799,12 +816,12 @@ class dr {
|
|
|
799
816
|
return r;
|
|
800
817
|
}
|
|
801
818
|
async grpcInit(e, t, r) {
|
|
802
|
-
return await this.grpcClient.get().init({ resourceId: e },
|
|
819
|
+
return await this.grpcClient.get().init({ resourceId: e }, $(t, r)).response;
|
|
803
820
|
}
|
|
804
821
|
async grpcGetPartUrl({ id: e, type: t }, r, n, o) {
|
|
805
822
|
return await this.grpcClient.get().getPartURL(
|
|
806
823
|
{ resourceId: e, partNumber: r, uploadedPartSize: n, isInternalUse: !1 },
|
|
807
|
-
|
|
824
|
+
$(t, o)
|
|
808
825
|
).response;
|
|
809
826
|
}
|
|
810
827
|
async grpcUpdateProgress({ id: e, type: t }, r, n) {
|
|
@@ -813,18 +830,18 @@ class dr {
|
|
|
813
830
|
resourceId: e,
|
|
814
831
|
bytesProcessed: r
|
|
815
832
|
},
|
|
816
|
-
|
|
833
|
+
$(t, n)
|
|
817
834
|
).response;
|
|
818
835
|
}
|
|
819
836
|
async grpcFinalize({ id: e, type: t }, r) {
|
|
820
|
-
return await this.grpcClient.get().finalize({ resourceId: e },
|
|
837
|
+
return await this.grpcClient.get().finalize({ resourceId: e }, $(t, r)).response;
|
|
821
838
|
}
|
|
822
839
|
}
|
|
823
|
-
async function
|
|
840
|
+
async function pr(s, e, t) {
|
|
824
841
|
let r;
|
|
825
842
|
try {
|
|
826
843
|
r = await w.open(s);
|
|
827
|
-
const n = Number(t - e), o = Number(e), c = Buffer.alloc(n), i = await
|
|
844
|
+
const n = Number(t - e), o = Number(e), c = Buffer.alloc(n), i = await gr(r, c, n, o);
|
|
828
845
|
return c.subarray(0, i);
|
|
829
846
|
} catch (n) {
|
|
830
847
|
throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new tt(`there is no file ${s} for uploading`) : n;
|
|
@@ -832,7 +849,7 @@ async function ur(s, e, t) {
|
|
|
832
849
|
await (r == null ? void 0 : r.close());
|
|
833
850
|
}
|
|
834
851
|
}
|
|
835
|
-
async function
|
|
852
|
+
async function gr(s, e, t, r) {
|
|
836
853
|
let n = 0;
|
|
837
854
|
for (; n < t; ) {
|
|
838
855
|
const { bytesRead: o } = await s.read(
|
|
@@ -847,18 +864,18 @@ async function pr(s, e, t, r) {
|
|
|
847
864
|
}
|
|
848
865
|
return n;
|
|
849
866
|
}
|
|
850
|
-
async function
|
|
867
|
+
async function fr(s, e) {
|
|
851
868
|
const t = BigInt(Math.floor((await w.stat(s)).mtimeMs / 1e3));
|
|
852
869
|
if (t > e)
|
|
853
870
|
throw new Xe(`file was modified, expected mtime: ${e}, got: ${t}.`);
|
|
854
871
|
}
|
|
855
|
-
function
|
|
872
|
+
function wr(s, e, t, r) {
|
|
856
873
|
if (s != 200)
|
|
857
874
|
throw new et(
|
|
858
875
|
`response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${r.uploadUrl}`
|
|
859
876
|
);
|
|
860
877
|
}
|
|
861
|
-
class
|
|
878
|
+
class mr extends g {
|
|
862
879
|
constructor() {
|
|
863
880
|
super("google.protobuf.Duration", [
|
|
864
881
|
{
|
|
@@ -944,8 +961,8 @@ class wr extends g {
|
|
|
944
961
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
945
962
|
}
|
|
946
963
|
}
|
|
947
|
-
const
|
|
948
|
-
class
|
|
964
|
+
const q = new mr();
|
|
965
|
+
class yr extends g {
|
|
949
966
|
constructor() {
|
|
950
967
|
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
951
968
|
}
|
|
@@ -973,8 +990,8 @@ class mr extends g {
|
|
|
973
990
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
974
991
|
}
|
|
975
992
|
}
|
|
976
|
-
new
|
|
977
|
-
class
|
|
993
|
+
new yr();
|
|
994
|
+
class br extends g {
|
|
978
995
|
constructor() {
|
|
979
996
|
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
980
997
|
{
|
|
@@ -1061,8 +1078,8 @@ class yr extends g {
|
|
|
1061
1078
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1062
1079
|
}
|
|
1063
1080
|
}
|
|
1064
|
-
const v = new
|
|
1065
|
-
class
|
|
1081
|
+
const v = new br();
|
|
1082
|
+
class kr extends g {
|
|
1066
1083
|
constructor() {
|
|
1067
1084
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1068
1085
|
}
|
|
@@ -1090,8 +1107,8 @@ class br extends g {
|
|
|
1090
1107
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1091
1108
|
}
|
|
1092
1109
|
}
|
|
1093
|
-
new
|
|
1094
|
-
class
|
|
1110
|
+
new kr();
|
|
1111
|
+
class Tr extends g {
|
|
1095
1112
|
constructor() {
|
|
1096
1113
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1097
1114
|
{
|
|
@@ -1133,8 +1150,8 @@ class kr extends g {
|
|
|
1133
1150
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1134
1151
|
}
|
|
1135
1152
|
}
|
|
1136
|
-
const
|
|
1137
|
-
class
|
|
1153
|
+
const Lr = new Tr();
|
|
1154
|
+
class Ur extends g {
|
|
1138
1155
|
constructor() {
|
|
1139
1156
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1140
1157
|
{ no: 1, name: "report", kind: "message", T: () => v }
|
|
@@ -1169,8 +1186,8 @@ class Lr extends g {
|
|
|
1169
1186
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1170
1187
|
}
|
|
1171
1188
|
}
|
|
1172
|
-
const
|
|
1173
|
-
class
|
|
1189
|
+
const Pr = new Ur();
|
|
1190
|
+
class Rr extends g {
|
|
1174
1191
|
constructor() {
|
|
1175
1192
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1176
1193
|
}
|
|
@@ -1198,8 +1215,8 @@ class Pr extends g {
|
|
|
1198
1215
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1199
1216
|
}
|
|
1200
1217
|
}
|
|
1201
|
-
new
|
|
1202
|
-
class
|
|
1218
|
+
new Rr();
|
|
1219
|
+
class Nr extends g {
|
|
1203
1220
|
constructor() {
|
|
1204
1221
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request", [
|
|
1205
1222
|
{
|
|
@@ -1210,7 +1227,7 @@ class Rr extends g {
|
|
|
1210
1227
|
L: 0
|
|
1211
1228
|
/*LongType.BIGINT*/
|
|
1212
1229
|
},
|
|
1213
|
-
{ no: 2, name: "update_interval", kind: "message", T: () =>
|
|
1230
|
+
{ no: 2, name: "update_interval", kind: "message", T: () => q }
|
|
1214
1231
|
]);
|
|
1215
1232
|
}
|
|
1216
1233
|
create(e) {
|
|
@@ -1228,7 +1245,7 @@ class Rr extends g {
|
|
|
1228
1245
|
break;
|
|
1229
1246
|
case /* google.protobuf.Duration update_interval */
|
|
1230
1247
|
2:
|
|
1231
|
-
o.updateInterval =
|
|
1248
|
+
o.updateInterval = q.internalBinaryRead(e, e.uint32(), r, o.updateInterval);
|
|
1232
1249
|
break;
|
|
1233
1250
|
default:
|
|
1234
1251
|
let a = r.readUnknownField;
|
|
@@ -1241,13 +1258,13 @@ class Rr extends g {
|
|
|
1241
1258
|
return o;
|
|
1242
1259
|
}
|
|
1243
1260
|
internalBinaryWrite(e, t, r) {
|
|
1244
|
-
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.updateInterval &&
|
|
1261
|
+
e.resourceId !== 0n && t.tag(1, p.Varint).uint64(e.resourceId), e.updateInterval && q.internalBinaryWrite(e.updateInterval, t.tag(2, p.LengthDelimited).fork(), r).join();
|
|
1245
1262
|
let n = r.writeUnknownFields;
|
|
1246
1263
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1247
1264
|
}
|
|
1248
1265
|
}
|
|
1249
|
-
const
|
|
1250
|
-
class
|
|
1266
|
+
const $r = new Nr();
|
|
1267
|
+
class Sr extends g {
|
|
1251
1268
|
constructor() {
|
|
1252
1269
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response", [
|
|
1253
1270
|
{ no: 1, name: "report", kind: "message", T: () => v }
|
|
@@ -1282,11 +1299,11 @@ class $r extends g {
|
|
|
1282
1299
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1283
1300
|
}
|
|
1284
1301
|
}
|
|
1285
|
-
const
|
|
1286
|
-
{ name: "GetStatus", options: { "google.api.http": { get: "/resources/{resource_id}/get-progress" } }, I:
|
|
1287
|
-
{ name: "RealtimeStatus", serverStreaming: !0, options: {}, I:
|
|
1302
|
+
const Ir = new Sr(), ie = new x("MiLaboratories.Controller.Shared.Progress", [
|
|
1303
|
+
{ name: "GetStatus", options: { "google.api.http": { get: "/resources/{resource_id}/get-progress" } }, I: Lr, O: Pr },
|
|
1304
|
+
{ name: "RealtimeStatus", serverStreaming: !0, options: {}, I: $r, O: Ir }
|
|
1288
1305
|
]);
|
|
1289
|
-
class
|
|
1306
|
+
class Dr {
|
|
1290
1307
|
constructor(e) {
|
|
1291
1308
|
h(this, "typeName", ie.typeName);
|
|
1292
1309
|
h(this, "methods", ie.methods);
|
|
@@ -1298,20 +1315,20 @@ class Ir {
|
|
|
1298
1315
|
*/
|
|
1299
1316
|
getStatus(e, t) {
|
|
1300
1317
|
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1301
|
-
return
|
|
1318
|
+
return R("unary", this._transport, r, n, e);
|
|
1302
1319
|
}
|
|
1303
1320
|
/**
|
|
1304
1321
|
* @generated from protobuf rpc: RealtimeStatus
|
|
1305
1322
|
*/
|
|
1306
1323
|
realtimeStatus(e, t) {
|
|
1307
1324
|
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
1308
|
-
return
|
|
1325
|
+
return R("serverStreaming", this._transport, r, n, e);
|
|
1309
1326
|
}
|
|
1310
1327
|
}
|
|
1311
|
-
class
|
|
1328
|
+
class vr {
|
|
1312
1329
|
constructor(e, t, r, n) {
|
|
1313
1330
|
h(this, "grpcClient");
|
|
1314
|
-
this.client = r, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new
|
|
1331
|
+
this.client = r, this.logger = n, this.grpcClient = e.createGrpcClientProvider((o) => new Dr(o));
|
|
1315
1332
|
}
|
|
1316
1333
|
close() {
|
|
1317
1334
|
}
|
|
@@ -1319,8 +1336,8 @@ class Dr {
|
|
|
1319
1336
|
async getStatus({ id: e, type: t }, r) {
|
|
1320
1337
|
const n = await this.grpcClient.get().getStatus(
|
|
1321
1338
|
{ resourceId: e },
|
|
1322
|
-
|
|
1323
|
-
), o =
|
|
1339
|
+
$(t, r)
|
|
1340
|
+
), o = K(n.response.report);
|
|
1324
1341
|
return {
|
|
1325
1342
|
done: o.done,
|
|
1326
1343
|
progress: o.progress,
|
|
@@ -1331,8 +1348,8 @@ class Dr {
|
|
|
1331
1348
|
// realtimeStatus returns a async generator that takes statuses from
|
|
1332
1349
|
// GRPC stream every updateIntervalMs milliseconds.
|
|
1333
1350
|
async *realtimeStatus({ id: e, type: t }, r = 100, n) {
|
|
1334
|
-
n =
|
|
1335
|
-
const o = Math.floor(r / 1e3), c = (r - o * 1e3) * 1e6, i =
|
|
1351
|
+
n = $(t, n);
|
|
1352
|
+
const o = Math.floor(r / 1e3), c = (r - o * 1e3) * 1e6, i = q.create({
|
|
1336
1353
|
seconds: BigInt(o),
|
|
1337
1354
|
nanos: c
|
|
1338
1355
|
});
|
|
@@ -1350,7 +1367,7 @@ class Dr {
|
|
|
1350
1367
|
}
|
|
1351
1368
|
}
|
|
1352
1369
|
}
|
|
1353
|
-
class
|
|
1370
|
+
class te extends Error {
|
|
1354
1371
|
constructor() {
|
|
1355
1372
|
super(...arguments);
|
|
1356
1373
|
h(this, "name", "NetworkError400");
|
|
@@ -1370,32 +1387,32 @@ class rt {
|
|
|
1370
1387
|
}), a = Ge.toWeb(i);
|
|
1371
1388
|
let d = !1;
|
|
1372
1389
|
try {
|
|
1373
|
-
await
|
|
1374
|
-
const
|
|
1375
|
-
return d = !0,
|
|
1376
|
-
} catch (
|
|
1390
|
+
await Br(c, a, e);
|
|
1391
|
+
const N = Number(l["content-length"]), m = await n(a, N);
|
|
1392
|
+
return d = !0, m;
|
|
1393
|
+
} catch (N) {
|
|
1377
1394
|
if (!d && !a.locked)
|
|
1378
1395
|
try {
|
|
1379
1396
|
await a.cancel();
|
|
1380
1397
|
} catch {
|
|
1381
1398
|
}
|
|
1382
|
-
throw
|
|
1399
|
+
throw N;
|
|
1383
1400
|
}
|
|
1384
1401
|
}
|
|
1385
1402
|
}
|
|
1386
|
-
async function
|
|
1403
|
+
async function Br(s, e, t) {
|
|
1387
1404
|
if (s != 200 && s != 206) {
|
|
1388
|
-
const r = (await
|
|
1389
|
-
throw 400 <= s && s < 500 ? new
|
|
1405
|
+
const r = (await It(e)).substring(0, 1e3);
|
|
1406
|
+
throw 400 <= s && s < 500 ? new te(
|
|
1390
1407
|
`Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${r}`
|
|
1391
1408
|
) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
|
|
1392
1409
|
}
|
|
1393
1410
|
}
|
|
1394
|
-
function
|
|
1395
|
-
if (!
|
|
1411
|
+
function O(s) {
|
|
1412
|
+
if (!U.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1396
1413
|
return s;
|
|
1397
1414
|
}
|
|
1398
|
-
class
|
|
1415
|
+
class Cr extends g {
|
|
1399
1416
|
constructor() {
|
|
1400
1417
|
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1401
1418
|
}
|
|
@@ -1423,8 +1440,8 @@ class Br extends g {
|
|
|
1423
1440
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1424
1441
|
}
|
|
1425
1442
|
}
|
|
1426
|
-
new
|
|
1427
|
-
class
|
|
1443
|
+
new Cr();
|
|
1444
|
+
class Er extends g {
|
|
1428
1445
|
constructor() {
|
|
1429
1446
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1430
1447
|
}
|
|
@@ -1452,8 +1469,8 @@ class Cr extends g {
|
|
|
1452
1469
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1453
1470
|
}
|
|
1454
1471
|
}
|
|
1455
|
-
new
|
|
1456
|
-
class
|
|
1472
|
+
new Er();
|
|
1473
|
+
class _r extends g {
|
|
1457
1474
|
constructor() {
|
|
1458
1475
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request", [
|
|
1459
1476
|
{
|
|
@@ -1506,8 +1523,8 @@ class Er extends g {
|
|
|
1506
1523
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1507
1524
|
}
|
|
1508
1525
|
}
|
|
1509
|
-
const
|
|
1510
|
-
class
|
|
1526
|
+
const Fr = new _r();
|
|
1527
|
+
class Or extends g {
|
|
1511
1528
|
constructor() {
|
|
1512
1529
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader", [
|
|
1513
1530
|
{
|
|
@@ -1561,8 +1578,8 @@ class Fr extends g {
|
|
|
1561
1578
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1562
1579
|
}
|
|
1563
1580
|
}
|
|
1564
|
-
const ae = new
|
|
1565
|
-
class
|
|
1581
|
+
const ae = new Or();
|
|
1582
|
+
class zr extends g {
|
|
1566
1583
|
constructor() {
|
|
1567
1584
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response", [
|
|
1568
1585
|
{
|
|
@@ -1610,10 +1627,10 @@ class Or extends g {
|
|
|
1610
1627
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1611
1628
|
}
|
|
1612
1629
|
}
|
|
1613
|
-
const
|
|
1614
|
-
{ name: "GetDownloadURL", options: { "google.api.http": { get: "/resources/{resource_id}/get-download-url" } }, I:
|
|
1630
|
+
const Wr = new zr(), le = new x("MiLaboratories.Controller.Shared.Download", [
|
|
1631
|
+
{ name: "GetDownloadURL", options: { "google.api.http": { get: "/resources/{resource_id}/get-download-url" } }, I: Fr, O: Wr }
|
|
1615
1632
|
]);
|
|
1616
|
-
class
|
|
1633
|
+
class xr {
|
|
1617
1634
|
constructor(e) {
|
|
1618
1635
|
h(this, "typeName", le.typeName);
|
|
1619
1636
|
h(this, "methods", le.methods);
|
|
@@ -1625,10 +1642,10 @@ class Wr {
|
|
|
1625
1642
|
*/
|
|
1626
1643
|
getDownloadURL(e, t) {
|
|
1627
1644
|
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1628
|
-
return
|
|
1645
|
+
return R("unary", this._transport, r, n, e);
|
|
1629
1646
|
}
|
|
1630
1647
|
}
|
|
1631
|
-
class
|
|
1648
|
+
class Ar {
|
|
1632
1649
|
constructor(e, t, r, n) {
|
|
1633
1650
|
h(this, "grpcClient");
|
|
1634
1651
|
h(this, "remoteFileDownloader");
|
|
@@ -1636,7 +1653,7 @@ class xr {
|
|
|
1636
1653
|
h(this, "localStorageIdsToRoot");
|
|
1637
1654
|
/** Concurrency limiter for local file reads - limit to 32 parallel reads */
|
|
1638
1655
|
h(this, "localFileReadLimiter", new He(32));
|
|
1639
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((o) => new
|
|
1656
|
+
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((o) => new xr(o)), this.remoteFileDownloader = new rt(t), this.localStorageIdsToRoot = Vr(n);
|
|
1640
1657
|
}
|
|
1641
1658
|
close() {
|
|
1642
1659
|
}
|
|
@@ -1648,24 +1665,24 @@ class xr {
|
|
|
1648
1665
|
*/
|
|
1649
1666
|
async withBlobContent(e, t, r, n) {
|
|
1650
1667
|
const { downloadUrl: o, headers: c } = await this.grpcGetDownloadUrl(e, t, r.signal), i = Object.fromEntries(c.map(({ name: l, value: a }) => [l, a]));
|
|
1651
|
-
return this.logger.info(`download blob ${
|
|
1668
|
+
return this.logger.info(`download blob ${y(e)} from url ${o}, ops: ${JSON.stringify(r)}`), Gr(o) ? await this.withLocalFileContent(o, r, n) : await this.remoteFileDownloader.withContent(o, i, r, n);
|
|
1652
1669
|
}
|
|
1653
1670
|
async withLocalFileContent(e, t, r) {
|
|
1654
|
-
const { storageId: n, relativePath: o } =
|
|
1671
|
+
const { storageId: n, relativePath: o } = Mr(e), c = Hr(n, this.localStorageIdsToRoot, o);
|
|
1655
1672
|
return await this.localFileReadLimiter.run(async () => {
|
|
1656
|
-
var d,
|
|
1673
|
+
var d, N;
|
|
1657
1674
|
const i = {
|
|
1658
1675
|
start: (d = t.range) == null ? void 0 : d.from,
|
|
1659
|
-
end: ((
|
|
1676
|
+
end: ((N = t.range) == null ? void 0 : N.to) !== void 0 ? t.range.to - 1 : void 0
|
|
1660
1677
|
};
|
|
1661
1678
|
let l, a = !1;
|
|
1662
1679
|
try {
|
|
1663
|
-
const
|
|
1680
|
+
const m = await w.stat(c);
|
|
1664
1681
|
l = Ne.createReadStream(c, i);
|
|
1665
|
-
const
|
|
1682
|
+
const E = Ge.toWeb(l), ne = await r(E, m.size);
|
|
1666
1683
|
return a = !0, ne;
|
|
1667
|
-
} catch (
|
|
1668
|
-
throw !a && l && !l.destroyed && l.destroy(),
|
|
1684
|
+
} catch (m) {
|
|
1685
|
+
throw !a && l && !l.destroyed && l.destroy(), m;
|
|
1669
1686
|
}
|
|
1670
1687
|
});
|
|
1671
1688
|
}
|
|
@@ -1673,11 +1690,11 @@ class xr {
|
|
|
1673
1690
|
const o = r ?? {};
|
|
1674
1691
|
return o.abort = n, await this.grpcClient.get().getDownloadURL(
|
|
1675
1692
|
{ resourceId: e, isInternalUse: !1 },
|
|
1676
|
-
|
|
1693
|
+
$(t, o)
|
|
1677
1694
|
).response;
|
|
1678
1695
|
}
|
|
1679
1696
|
}
|
|
1680
|
-
function
|
|
1697
|
+
function Mr(s) {
|
|
1681
1698
|
const e = new URL(s);
|
|
1682
1699
|
if (e.pathname == "")
|
|
1683
1700
|
throw new $e(`url for local filepath ${s} does not match url scheme`);
|
|
@@ -1686,14 +1703,14 @@ function Ar(s) {
|
|
|
1686
1703
|
relativePath: decodeURIComponent(e.pathname.slice(1))
|
|
1687
1704
|
};
|
|
1688
1705
|
}
|
|
1689
|
-
function
|
|
1706
|
+
function Hr(s, e, t) {
|
|
1690
1707
|
const r = e.get(s);
|
|
1691
1708
|
if (r === void 0) throw new Se(`Unknown storage location: ${s}`);
|
|
1692
|
-
return r === "" ? t :
|
|
1709
|
+
return r === "" ? t : T.join(r, t);
|
|
1693
1710
|
}
|
|
1694
|
-
const
|
|
1695
|
-
function
|
|
1696
|
-
return s.startsWith(
|
|
1711
|
+
const jr = "storage://";
|
|
1712
|
+
function Gr(s) {
|
|
1713
|
+
return s.startsWith(jr);
|
|
1697
1714
|
}
|
|
1698
1715
|
class $e extends Error {
|
|
1699
1716
|
constructor() {
|
|
@@ -1707,13 +1724,13 @@ class Se extends Error {
|
|
|
1707
1724
|
h(this, "name", "UnknownStorageError");
|
|
1708
1725
|
}
|
|
1709
1726
|
}
|
|
1710
|
-
function
|
|
1727
|
+
function Vr(s) {
|
|
1711
1728
|
const e = /* @__PURE__ */ new Map();
|
|
1712
1729
|
for (const t of s)
|
|
1713
|
-
t.localPath !== "" &&
|
|
1730
|
+
t.localPath !== "" && O(t.localPath), e.set(t.storageId, t.localPath);
|
|
1714
1731
|
return e;
|
|
1715
1732
|
}
|
|
1716
|
-
class
|
|
1733
|
+
class qr extends g {
|
|
1717
1734
|
constructor() {
|
|
1718
1735
|
super("google.protobuf.Timestamp", [
|
|
1719
1736
|
{
|
|
@@ -1820,8 +1837,8 @@ class Vr extends g {
|
|
|
1820
1837
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1821
1838
|
}
|
|
1822
1839
|
}
|
|
1823
|
-
const ce = new
|
|
1824
|
-
class
|
|
1840
|
+
const ce = new qr();
|
|
1841
|
+
class Jr extends g {
|
|
1825
1842
|
constructor() {
|
|
1826
1843
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
1827
1844
|
}
|
|
@@ -1849,8 +1866,8 @@ class qr extends g {
|
|
|
1849
1866
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1850
1867
|
}
|
|
1851
1868
|
}
|
|
1852
|
-
new
|
|
1853
|
-
class
|
|
1869
|
+
new Jr();
|
|
1870
|
+
class Zr extends g {
|
|
1854
1871
|
constructor() {
|
|
1855
1872
|
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
1856
1873
|
{
|
|
@@ -1952,8 +1969,8 @@ class Jr extends g {
|
|
|
1952
1969
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1953
1970
|
}
|
|
1954
1971
|
}
|
|
1955
|
-
const he = new
|
|
1956
|
-
class
|
|
1972
|
+
const he = new Zr();
|
|
1973
|
+
class Qr extends g {
|
|
1957
1974
|
constructor() {
|
|
1958
1975
|
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
1959
1976
|
}
|
|
@@ -1981,8 +1998,8 @@ class Zr extends g {
|
|
|
1981
1998
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
1982
1999
|
}
|
|
1983
2000
|
}
|
|
1984
|
-
new
|
|
1985
|
-
class
|
|
2001
|
+
new Qr();
|
|
2002
|
+
class Kr extends g {
|
|
1986
2003
|
constructor() {
|
|
1987
2004
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
1988
2005
|
{
|
|
@@ -2035,8 +2052,8 @@ class Qr extends g {
|
|
|
2035
2052
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2036
2053
|
}
|
|
2037
2054
|
}
|
|
2038
|
-
const
|
|
2039
|
-
class
|
|
2055
|
+
const Xr = new Kr();
|
|
2056
|
+
class Yr extends g {
|
|
2040
2057
|
constructor() {
|
|
2041
2058
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2042
2059
|
{ no: 1, name: "items", kind: "message", repeat: 2, T: () => he },
|
|
@@ -2084,10 +2101,10 @@ class Xr extends g {
|
|
|
2084
2101
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2085
2102
|
}
|
|
2086
2103
|
}
|
|
2087
|
-
const
|
|
2088
|
-
{ name: "List", options: {}, I:
|
|
2104
|
+
const en = new Yr(), de = new x("MiLaboratories.Controller.Shared.LS", [
|
|
2105
|
+
{ name: "List", options: {}, I: Xr, O: en }
|
|
2089
2106
|
]);
|
|
2090
|
-
class
|
|
2107
|
+
class tn {
|
|
2091
2108
|
constructor(e) {
|
|
2092
2109
|
h(this, "typeName", de.typeName);
|
|
2093
2110
|
h(this, "methods", de.methods);
|
|
@@ -2099,13 +2116,13 @@ class en {
|
|
|
2099
2116
|
*/
|
|
2100
2117
|
list(e, t) {
|
|
2101
2118
|
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
2102
|
-
return
|
|
2119
|
+
return R("unary", this._transport, r, n, e);
|
|
2103
2120
|
}
|
|
2104
2121
|
}
|
|
2105
|
-
class
|
|
2122
|
+
class rn {
|
|
2106
2123
|
constructor(e, t) {
|
|
2107
2124
|
h(this, "grpcClient");
|
|
2108
|
-
this.logger = t, this.grpcClient = e.createGrpcClientProvider((r) => new
|
|
2125
|
+
this.logger = t, this.grpcClient = e.createGrpcClientProvider((r) => new tn(r));
|
|
2109
2126
|
}
|
|
2110
2127
|
close() {
|
|
2111
2128
|
}
|
|
@@ -2115,11 +2132,11 @@ class tn {
|
|
|
2115
2132
|
resourceId: e.id,
|
|
2116
2133
|
location: t
|
|
2117
2134
|
},
|
|
2118
|
-
|
|
2135
|
+
$(e.type, r)
|
|
2119
2136
|
).response;
|
|
2120
2137
|
}
|
|
2121
2138
|
}
|
|
2122
|
-
class
|
|
2139
|
+
class nn extends g {
|
|
2123
2140
|
constructor() {
|
|
2124
2141
|
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2125
2142
|
}
|
|
@@ -2147,8 +2164,8 @@ class rn extends g {
|
|
|
2147
2164
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2148
2165
|
}
|
|
2149
2166
|
}
|
|
2150
|
-
new
|
|
2151
|
-
class
|
|
2167
|
+
new nn();
|
|
2168
|
+
class on extends g {
|
|
2152
2169
|
constructor() {
|
|
2153
2170
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2154
2171
|
{
|
|
@@ -2227,8 +2244,8 @@ class nn extends g {
|
|
|
2227
2244
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2228
2245
|
}
|
|
2229
2246
|
}
|
|
2230
|
-
const
|
|
2231
|
-
class
|
|
2247
|
+
const sn = new on();
|
|
2248
|
+
class an extends g {
|
|
2232
2249
|
constructor() {
|
|
2233
2250
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2234
2251
|
{
|
|
@@ -2294,8 +2311,8 @@ class sn extends g {
|
|
|
2294
2311
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2295
2312
|
}
|
|
2296
2313
|
}
|
|
2297
|
-
const
|
|
2298
|
-
class
|
|
2314
|
+
const ln = new an();
|
|
2315
|
+
class cn extends g {
|
|
2299
2316
|
constructor() {
|
|
2300
2317
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2301
2318
|
{
|
|
@@ -2386,8 +2403,8 @@ class ln extends g {
|
|
|
2386
2403
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2387
2404
|
}
|
|
2388
2405
|
}
|
|
2389
|
-
const
|
|
2390
|
-
class
|
|
2406
|
+
const hn = new cn();
|
|
2407
|
+
class dn extends g {
|
|
2391
2408
|
constructor() {
|
|
2392
2409
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2393
2410
|
{
|
|
@@ -2478,8 +2495,8 @@ class hn extends g {
|
|
|
2478
2495
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2479
2496
|
}
|
|
2480
2497
|
}
|
|
2481
|
-
const
|
|
2482
|
-
class
|
|
2498
|
+
const un = new dn();
|
|
2499
|
+
class pn extends g {
|
|
2483
2500
|
constructor() {
|
|
2484
2501
|
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2485
2502
|
{
|
|
@@ -2570,8 +2587,8 @@ class un extends g {
|
|
|
2570
2587
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2571
2588
|
}
|
|
2572
2589
|
}
|
|
2573
|
-
const
|
|
2574
|
-
class
|
|
2590
|
+
const gn = new pn();
|
|
2591
|
+
class fn extends g {
|
|
2575
2592
|
constructor() {
|
|
2576
2593
|
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2577
2594
|
{
|
|
@@ -2636,14 +2653,14 @@ class gn extends g {
|
|
|
2636
2653
|
return n !== !1 && (n == !0 ? u.onWrite : n)(this.typeName, e, t), t;
|
|
2637
2654
|
}
|
|
2638
2655
|
}
|
|
2639
|
-
const
|
|
2640
|
-
{ name: "StreamBinary", serverStreaming: !0, options: {}, I:
|
|
2641
|
-
{ name: "ReadBinary", options: {}, I:
|
|
2642
|
-
{ name: "StreamText", serverStreaming: !0, options: {}, I:
|
|
2643
|
-
{ name: "ReadText", options: {}, I:
|
|
2644
|
-
{ name: "LastLines", options: {}, I:
|
|
2656
|
+
const _ = new fn(), ue = new x("MiLaboratories.Controller.Shared.Streaming", [
|
|
2657
|
+
{ name: "StreamBinary", serverStreaming: !0, options: {}, I: sn, O: _ },
|
|
2658
|
+
{ name: "ReadBinary", options: {}, I: ln, O: _ },
|
|
2659
|
+
{ name: "StreamText", serverStreaming: !0, options: {}, I: hn, O: _ },
|
|
2660
|
+
{ name: "ReadText", options: {}, I: un, O: _ },
|
|
2661
|
+
{ name: "LastLines", options: {}, I: gn, O: _ }
|
|
2645
2662
|
]);
|
|
2646
|
-
class
|
|
2663
|
+
class wn {
|
|
2647
2664
|
constructor(e) {
|
|
2648
2665
|
h(this, "typeName", ue.typeName);
|
|
2649
2666
|
h(this, "methods", ue.methods);
|
|
@@ -2659,7 +2676,7 @@ class fn {
|
|
|
2659
2676
|
*/
|
|
2660
2677
|
streamBinary(e, t) {
|
|
2661
2678
|
const r = this.methods[0], n = this._transport.mergeOptions(t);
|
|
2662
|
-
return
|
|
2679
|
+
return R("serverStreaming", this._transport, r, n, e);
|
|
2663
2680
|
}
|
|
2664
2681
|
/**
|
|
2665
2682
|
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
@@ -2671,7 +2688,7 @@ class fn {
|
|
|
2671
2688
|
*/
|
|
2672
2689
|
readBinary(e, t) {
|
|
2673
2690
|
const r = this.methods[1], n = this._transport.mergeOptions(t);
|
|
2674
|
-
return
|
|
2691
|
+
return R("unary", this._transport, r, n, e);
|
|
2675
2692
|
}
|
|
2676
2693
|
/**
|
|
2677
2694
|
* StreamText provides stream of textual file, splitting the data by newline symbol.
|
|
@@ -2681,7 +2698,7 @@ class fn {
|
|
|
2681
2698
|
*/
|
|
2682
2699
|
streamText(e, t) {
|
|
2683
2700
|
const r = this.methods[2], n = this._transport.mergeOptions(t);
|
|
2684
|
-
return
|
|
2701
|
+
return R("serverStreaming", this._transport, r, n, e);
|
|
2685
2702
|
}
|
|
2686
2703
|
/**
|
|
2687
2704
|
* ReadBinary allows to read remote item in chunks using stream-like API.
|
|
@@ -2693,7 +2710,7 @@ class fn {
|
|
|
2693
2710
|
*/
|
|
2694
2711
|
readText(e, t) {
|
|
2695
2712
|
const r = this.methods[3], n = this._transport.mergeOptions(t);
|
|
2696
|
-
return
|
|
2713
|
+
return R("unary", this._transport, r, n, e);
|
|
2697
2714
|
}
|
|
2698
2715
|
/**
|
|
2699
2716
|
* LastLines provides single message with the last lines from data source.
|
|
@@ -2709,13 +2726,13 @@ class fn {
|
|
|
2709
2726
|
*/
|
|
2710
2727
|
lastLines(e, t) {
|
|
2711
2728
|
const r = this.methods[4], n = this._transport.mergeOptions(t);
|
|
2712
|
-
return
|
|
2729
|
+
return R("unary", this._transport, r, n, e);
|
|
2713
2730
|
}
|
|
2714
2731
|
}
|
|
2715
|
-
class
|
|
2732
|
+
class mn {
|
|
2716
2733
|
constructor(e, t, r) {
|
|
2717
2734
|
h(this, "grpcClient");
|
|
2718
|
-
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((n) => new
|
|
2735
|
+
this.httpClient = t, this.logger = r, this.grpcClient = e.createGrpcClientProvider((n) => new wn(n));
|
|
2719
2736
|
}
|
|
2720
2737
|
close() {
|
|
2721
2738
|
}
|
|
@@ -2730,7 +2747,7 @@ class wn {
|
|
|
2730
2747
|
offset: n,
|
|
2731
2748
|
search: o
|
|
2732
2749
|
},
|
|
2733
|
-
|
|
2750
|
+
$(t, c)
|
|
2734
2751
|
)).response;
|
|
2735
2752
|
}
|
|
2736
2753
|
/** Reads the file forward and returns the text,
|
|
@@ -2739,48 +2756,48 @@ class wn {
|
|
|
2739
2756
|
async readText({ id: e, type: t }, r, n = 0n, o, c) {
|
|
2740
2757
|
return (await this.grpcClient.get().readText(
|
|
2741
2758
|
{
|
|
2742
|
-
resourceId:
|
|
2759
|
+
resourceId: K(e),
|
|
2743
2760
|
readLimit: BigInt(r),
|
|
2744
2761
|
offset: n,
|
|
2745
2762
|
search: o
|
|
2746
2763
|
},
|
|
2747
|
-
|
|
2764
|
+
$(t, c)
|
|
2748
2765
|
)).response;
|
|
2749
2766
|
}
|
|
2750
2767
|
}
|
|
2751
|
-
function
|
|
2768
|
+
function rs(s, e, t) {
|
|
2752
2769
|
return e.getDriver({
|
|
2753
2770
|
name: "DownloadBlob",
|
|
2754
|
-
init: (r, n, o) => new
|
|
2771
|
+
init: (r, n, o) => new Ar(n, o, s, t)
|
|
2755
2772
|
});
|
|
2756
2773
|
}
|
|
2757
|
-
function
|
|
2774
|
+
function ns(s, e) {
|
|
2758
2775
|
return s.getDriver({
|
|
2759
2776
|
name: "StreamLogs",
|
|
2760
|
-
init: (t, r, n) => new
|
|
2777
|
+
init: (t, r, n) => new mn(r, n, e)
|
|
2761
2778
|
});
|
|
2762
2779
|
}
|
|
2763
|
-
function
|
|
2780
|
+
function os(s, e) {
|
|
2764
2781
|
return s.getDriver({
|
|
2765
2782
|
name: "UploadProgress",
|
|
2766
|
-
init: (t, r, n) => new
|
|
2783
|
+
init: (t, r, n) => new vr(r, n, s, e)
|
|
2767
2784
|
});
|
|
2768
2785
|
}
|
|
2769
|
-
function
|
|
2786
|
+
function ss(s, e) {
|
|
2770
2787
|
return s.getDriver({
|
|
2771
2788
|
name: "UploadBlob",
|
|
2772
|
-
init: (t, r, n) => new
|
|
2789
|
+
init: (t, r, n) => new ur(r, n, s, e)
|
|
2773
2790
|
});
|
|
2774
2791
|
}
|
|
2775
|
-
function
|
|
2792
|
+
function yn(s, e) {
|
|
2776
2793
|
return s.getDriver({
|
|
2777
2794
|
name: "LsFiles",
|
|
2778
|
-
init: (t, r, n) => new
|
|
2795
|
+
init: (t, r, n) => new rn(r, e)
|
|
2779
2796
|
});
|
|
2780
2797
|
}
|
|
2781
|
-
const
|
|
2798
|
+
const bn = new He(32);
|
|
2782
2799
|
async function Ee(s, e) {
|
|
2783
|
-
return await
|
|
2800
|
+
return await bn.run(async () => {
|
|
2784
2801
|
const t = {};
|
|
2785
2802
|
e && (t.start = e.from, t.end = e.to - 1);
|
|
2786
2803
|
let r;
|
|
@@ -2792,10 +2809,10 @@ async function Ee(s, e) {
|
|
|
2792
2809
|
});
|
|
2793
2810
|
}
|
|
2794
2811
|
const nt = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
2795
|
-
function
|
|
2812
|
+
function kn(s, e) {
|
|
2796
2813
|
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
2797
2814
|
}
|
|
2798
|
-
function
|
|
2815
|
+
function Tn(s) {
|
|
2799
2816
|
return !!s.match(nt);
|
|
2800
2817
|
}
|
|
2801
2818
|
function pe(s, e) {
|
|
@@ -2805,10 +2822,10 @@ function pe(s, e) {
|
|
|
2805
2822
|
const { path: r, signature: n } = t.groups;
|
|
2806
2823
|
return e.verify(r, n, `Signature verification failed for: ${s}`), { path: r, signature: n };
|
|
2807
2824
|
}
|
|
2808
|
-
const
|
|
2825
|
+
const Ln = ee({
|
|
2809
2826
|
kv: {
|
|
2810
|
-
"ctl/file/blobInfo":
|
|
2811
|
-
sizeBytes:
|
|
2827
|
+
"ctl/file/blobInfo": L.object({
|
|
2828
|
+
sizeBytes: L.coerce.number()
|
|
2812
2829
|
})
|
|
2813
2830
|
}
|
|
2814
2831
|
});
|
|
@@ -2822,41 +2839,41 @@ function ot(s, e) {
|
|
|
2822
2839
|
}
|
|
2823
2840
|
return t;
|
|
2824
2841
|
}
|
|
2825
|
-
const
|
|
2842
|
+
const re = L.object({
|
|
2826
2843
|
/** Local file path, to take data for upload */
|
|
2827
|
-
localPath:
|
|
2844
|
+
localPath: L.string(),
|
|
2828
2845
|
/** Path signature, to check this data was generated by us */
|
|
2829
|
-
pathSignature:
|
|
2846
|
+
pathSignature: L.string(),
|
|
2830
2847
|
/** File size in bytes */
|
|
2831
|
-
sizeBytes:
|
|
2848
|
+
sizeBytes: L.string(),
|
|
2832
2849
|
/** Modification time unix timestamp in seconds */
|
|
2833
|
-
modificationTime:
|
|
2834
|
-
}), st =
|
|
2850
|
+
modificationTime: L.string()
|
|
2851
|
+
}), st = L.object({
|
|
2835
2852
|
/** Pl storage id */
|
|
2836
|
-
storageId:
|
|
2853
|
+
storageId: L.string(),
|
|
2837
2854
|
/** Path inside storage */
|
|
2838
|
-
path:
|
|
2839
|
-
}),
|
|
2840
|
-
|
|
2855
|
+
path: L.string()
|
|
2856
|
+
}), is = L.union([
|
|
2857
|
+
re,
|
|
2841
2858
|
st
|
|
2842
|
-
]),
|
|
2843
|
-
data:
|
|
2859
|
+
]), Un = ee({
|
|
2860
|
+
data: re,
|
|
2844
2861
|
fields: {
|
|
2845
2862
|
blob: !1
|
|
2846
2863
|
}
|
|
2847
|
-
}),
|
|
2864
|
+
}), Pn = ee({
|
|
2848
2865
|
fields: {
|
|
2849
2866
|
incarnation: !1
|
|
2850
2867
|
}
|
|
2851
2868
|
}), it = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.+)\/(?<resourceVersion>.+?)\/(?<resourceId>\d+?)\/(?<size>\d+?))#(?<signature>.*)$/;
|
|
2852
|
-
function
|
|
2869
|
+
function Rn(s, e) {
|
|
2853
2870
|
let t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}/${ot(s)}`;
|
|
2854
2871
|
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
2855
2872
|
}
|
|
2856
|
-
function
|
|
2873
|
+
function Nn(s) {
|
|
2857
2874
|
return !!s.match(it);
|
|
2858
2875
|
}
|
|
2859
|
-
function
|
|
2876
|
+
function $n(s, e) {
|
|
2860
2877
|
const t = s.match(it);
|
|
2861
2878
|
if (t === null)
|
|
2862
2879
|
throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
@@ -2875,7 +2892,7 @@ class Ie extends Error {
|
|
|
2875
2892
|
h(this, "name", "WrongResourceTypeError");
|
|
2876
2893
|
}
|
|
2877
2894
|
}
|
|
2878
|
-
class
|
|
2895
|
+
class Sn {
|
|
2879
2896
|
constructor(e) {
|
|
2880
2897
|
h(this, "updating");
|
|
2881
2898
|
this.onUpdate = e;
|
|
@@ -2896,18 +2913,18 @@ function at(s, e) {
|
|
|
2896
2913
|
return s ? `log+live://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}` : `log+ready://log/${e.type.name}/${e.type.version}/${BigInt(e.id)}`;
|
|
2897
2914
|
}
|
|
2898
2915
|
const lt = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
2899
|
-
function
|
|
2916
|
+
function Z(s) {
|
|
2900
2917
|
return lt.test(s);
|
|
2901
2918
|
}
|
|
2902
2919
|
const ct = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
2903
|
-
function
|
|
2920
|
+
function In(s) {
|
|
2904
2921
|
return ct.test(s);
|
|
2905
2922
|
}
|
|
2906
|
-
function
|
|
2923
|
+
function Q(s) {
|
|
2907
2924
|
let e;
|
|
2908
|
-
if (
|
|
2925
|
+
if (Z(s))
|
|
2909
2926
|
e = s.match(lt);
|
|
2910
|
-
else if (
|
|
2927
|
+
else if (In(s))
|
|
2911
2928
|
e = s.match(ct);
|
|
2912
2929
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
2913
2930
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
@@ -2917,13 +2934,13 @@ function Z(s) {
|
|
|
2917
2934
|
type: { name: t, version: r }
|
|
2918
2935
|
};
|
|
2919
2936
|
}
|
|
2920
|
-
function
|
|
2937
|
+
function k(s) {
|
|
2921
2938
|
return `${BigInt(s)}`;
|
|
2922
2939
|
}
|
|
2923
2940
|
function _e(s) {
|
|
2924
|
-
return
|
|
2941
|
+
return T.basename(s);
|
|
2925
2942
|
}
|
|
2926
|
-
class
|
|
2943
|
+
class Dn {
|
|
2927
2944
|
constructor(e, t, r, n, o) {
|
|
2928
2945
|
h(this, "change", new C());
|
|
2929
2946
|
h(this, "signalCtl", new AbortController());
|
|
@@ -2950,14 +2967,14 @@ class In {
|
|
|
2950
2967
|
async download() {
|
|
2951
2968
|
try {
|
|
2952
2969
|
const e = await this.ensureDownloaded();
|
|
2953
|
-
this.setDone(e), this.change.markChanged(`blob download for ${
|
|
2970
|
+
this.setDone(e), this.change.markChanged(`blob download for ${P(this.rInfo.id)} finished`);
|
|
2954
2971
|
} catch (e) {
|
|
2955
|
-
throw this.logger.error(`download blob ${
|
|
2972
|
+
throw this.logger.error(`download blob ${y(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`), De(e) && (this.setError(e), this.change.markChanged(`blob download for ${P(this.rInfo.id)} failed`), await w.rm(this.path, { force: !0 })), e;
|
|
2956
2973
|
}
|
|
2957
2974
|
}
|
|
2958
2975
|
async ensureDownloaded() {
|
|
2959
|
-
this.signalCtl.signal.throwIfAborted(), this.state = {}, this.state.filePath = this.path, await
|
|
2960
|
-
const e = await
|
|
2976
|
+
this.signalCtl.signal.throwIfAborted(), this.state = {}, this.state.filePath = this.path, await W(T.dirname(this.state.filePath)), this.signalCtl.signal.throwIfAborted(), this.state.dirExists = !0;
|
|
2977
|
+
const e = await A(this.state.filePath);
|
|
2961
2978
|
if (this.signalCtl.signal.throwIfAborted(), e) {
|
|
2962
2979
|
this.state.fileExists = !0, this.logger.info(`a blob was already downloaded: ${this.state.filePath}`);
|
|
2963
2980
|
const r = await w.stat(this.state.filePath);
|
|
@@ -2967,8 +2984,8 @@ class In {
|
|
|
2967
2984
|
this.rInfo,
|
|
2968
2985
|
{},
|
|
2969
2986
|
{ signal: this.signalCtl.signal },
|
|
2970
|
-
async (r, n) => (this.state.fileSize = n, this.state.downloaded = !0, await
|
|
2971
|
-
const c =
|
|
2987
|
+
async (r, n) => (this.state.fileSize = n, this.state.downloaded = !0, await X(this.logger, this.state.filePath, async (o) => {
|
|
2988
|
+
const c = z.toWeb(ye.createWriteStream(o, { flags: "wx" }));
|
|
2972
2989
|
await r.pipeTo(c, { signal: this.signalCtl.signal }), this.state.tempWritten = !0;
|
|
2973
2990
|
}), this.state.done = !0, n)
|
|
2974
2991
|
);
|
|
@@ -2979,7 +2996,7 @@ class In {
|
|
|
2979
2996
|
getBlob() {
|
|
2980
2997
|
return this.done ? {
|
|
2981
2998
|
done: this.done,
|
|
2982
|
-
result:
|
|
2999
|
+
result: vn(this.handle, this.size, this.error)
|
|
2983
3000
|
} : { done: !1 };
|
|
2984
3001
|
}
|
|
2985
3002
|
setDone(e) {
|
|
@@ -2990,7 +3007,7 @@ class In {
|
|
|
2990
3007
|
}
|
|
2991
3008
|
}
|
|
2992
3009
|
function De(s) {
|
|
2993
|
-
return s instanceof ht || s instanceof
|
|
3010
|
+
return s instanceof ht || s instanceof te || s instanceof Se || s instanceof $e || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
|
|
2994
3011
|
}
|
|
2995
3012
|
class ht extends Error {
|
|
2996
3013
|
constructor() {
|
|
@@ -2998,7 +3015,7 @@ class ht extends Error {
|
|
|
2998
3015
|
h(this, "name", "DownloadAborted");
|
|
2999
3016
|
}
|
|
3000
3017
|
}
|
|
3001
|
-
function
|
|
3018
|
+
function vn(s, e, t) {
|
|
3002
3019
|
return t ? { ok: !1, error: t } : s ? {
|
|
3003
3020
|
ok: !0,
|
|
3004
3021
|
value: {
|
|
@@ -3047,19 +3064,19 @@ class ve {
|
|
|
3047
3064
|
this.cache.delete(e.path), this.totalSizeBytes -= e.size;
|
|
3048
3065
|
}
|
|
3049
3066
|
}
|
|
3050
|
-
const
|
|
3051
|
-
ranges:
|
|
3052
|
-
}),
|
|
3053
|
-
function
|
|
3054
|
-
return s +
|
|
3067
|
+
const Bn = L.object({
|
|
3068
|
+
ranges: L.array(Dt)
|
|
3069
|
+
}), Cn = ".ranges.json";
|
|
3070
|
+
function En(s) {
|
|
3071
|
+
return s + Cn;
|
|
3055
3072
|
}
|
|
3056
|
-
async function
|
|
3073
|
+
async function _n(s, e) {
|
|
3057
3074
|
let t = { ranges: [] };
|
|
3058
3075
|
try {
|
|
3059
3076
|
const r = await w.readFile(e, "utf8");
|
|
3060
|
-
t =
|
|
3077
|
+
t = Bn.parse(JSON.parse(r));
|
|
3061
3078
|
} catch (r) {
|
|
3062
|
-
if (r instanceof SyntaxError || r instanceof
|
|
3079
|
+
if (r instanceof SyntaxError || r instanceof L.ZodError) {
|
|
3063
3080
|
const n = `readRangesFile: the file ${e} was corrupted: ${r}`;
|
|
3064
3081
|
throw s.error(n), new ut(n);
|
|
3065
3082
|
}
|
|
@@ -3068,44 +3085,44 @@ async function En(s, e) {
|
|
|
3068
3085
|
}
|
|
3069
3086
|
return dt(t), t;
|
|
3070
3087
|
}
|
|
3071
|
-
async function
|
|
3072
|
-
await
|
|
3088
|
+
async function Fn(s, e, t) {
|
|
3089
|
+
await X(s, e, async (r) => {
|
|
3073
3090
|
await w.writeFile(r, JSON.stringify(t, null, 2), { flag: "wx" });
|
|
3074
3091
|
});
|
|
3075
3092
|
}
|
|
3076
3093
|
function dt(s) {
|
|
3077
3094
|
s.ranges.sort((e, t) => e.from - t.from);
|
|
3078
3095
|
for (let e = 0; e < s.ranges.length - 1; e++)
|
|
3079
|
-
s.ranges[e].to >= s.ranges[e + 1].from && (
|
|
3096
|
+
s.ranges[e].to >= s.ranges[e + 1].from && (On(s, e), e--);
|
|
3080
3097
|
}
|
|
3081
|
-
function
|
|
3098
|
+
function On(s, e) {
|
|
3082
3099
|
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);
|
|
3083
3100
|
s.ranges.splice(e, 2, { from: t, to: r });
|
|
3084
3101
|
}
|
|
3085
|
-
function
|
|
3102
|
+
function H(s) {
|
|
3086
3103
|
return s.ranges.reduce((e, t) => e + t.to - t.from, 0);
|
|
3087
3104
|
}
|
|
3088
|
-
function
|
|
3105
|
+
function zn(s, e) {
|
|
3089
3106
|
for (const t of s.ranges)
|
|
3090
3107
|
if (t.from <= e.from && e.to <= t.to)
|
|
3091
3108
|
return !0;
|
|
3092
3109
|
return !1;
|
|
3093
3110
|
}
|
|
3094
|
-
function
|
|
3111
|
+
function Wn(s, e) {
|
|
3095
3112
|
return s.ranges.push(e), dt(s), s;
|
|
3096
3113
|
}
|
|
3097
|
-
async function
|
|
3114
|
+
async function xn(s, e, t) {
|
|
3098
3115
|
try {
|
|
3099
|
-
await (await w.open(e, "w")).close(), await
|
|
3116
|
+
await (await w.open(e, "w")).close(), await An(e, t);
|
|
3100
3117
|
} catch (r) {
|
|
3101
3118
|
s.error(`Error creating file ${e} on platform ${t}: ${r}`);
|
|
3102
3119
|
}
|
|
3103
3120
|
}
|
|
3104
|
-
async function
|
|
3105
|
-
e === "win32" && await
|
|
3121
|
+
async function An(s, e) {
|
|
3122
|
+
e === "win32" && await $t("fsutil", ["sparse", "setflag", `"${s}"`], { stdio: "pipe" });
|
|
3106
3123
|
}
|
|
3107
|
-
async function
|
|
3108
|
-
await
|
|
3124
|
+
async function Mn(s, e, t, r, n) {
|
|
3125
|
+
await A(t) || await xn(s, t, e);
|
|
3109
3126
|
const o = await w.open(t, "r+");
|
|
3110
3127
|
await o.write(r, 0, r.length, n), await o.close();
|
|
3111
3128
|
}
|
|
@@ -3115,49 +3132,49 @@ class ut extends Error {
|
|
|
3115
3132
|
h(this, "name", "CorruptedRangesError");
|
|
3116
3133
|
}
|
|
3117
3134
|
}
|
|
3118
|
-
class
|
|
3135
|
+
class Hn {
|
|
3119
3136
|
constructor(e, t) {
|
|
3120
3137
|
this.logger = e, this.cacheDir = t;
|
|
3121
3138
|
}
|
|
3122
3139
|
fPath(e) {
|
|
3123
|
-
return
|
|
3140
|
+
return U.join(this.cacheDir, En(e));
|
|
3124
3141
|
}
|
|
3125
3142
|
async get(e) {
|
|
3126
|
-
return await
|
|
3143
|
+
return await _n(this.logger, this.fPath(e));
|
|
3127
3144
|
}
|
|
3128
3145
|
async set(e, t) {
|
|
3129
|
-
return await
|
|
3146
|
+
return await Fn(this.logger, this.fPath(e), t);
|
|
3130
3147
|
}
|
|
3131
3148
|
async delete(e) {
|
|
3132
3149
|
await be.rm(this.fPath(e));
|
|
3133
3150
|
}
|
|
3134
3151
|
}
|
|
3135
|
-
class
|
|
3152
|
+
class jn {
|
|
3136
3153
|
constructor(e, t) {
|
|
3137
3154
|
h(this, "suffix", ".sparse.bin");
|
|
3138
3155
|
this.logger = e, this.cacheDir = t;
|
|
3139
3156
|
}
|
|
3140
3157
|
async all() {
|
|
3141
|
-
return await
|
|
3158
|
+
return await W(this.cacheDir), (await be.readdir(this.cacheDir)).filter((t) => t.endsWith(this.suffix));
|
|
3142
3159
|
}
|
|
3143
3160
|
async exists(e) {
|
|
3144
|
-
return await
|
|
3161
|
+
return await A(this.path(e));
|
|
3145
3162
|
}
|
|
3146
3163
|
path(e) {
|
|
3147
|
-
return
|
|
3164
|
+
return U.join(this.cacheDir, e + this.suffix);
|
|
3148
3165
|
}
|
|
3149
3166
|
async write(e, t, r) {
|
|
3150
|
-
await
|
|
3167
|
+
await W(this.cacheDir), await Mn(this.logger, process.platform, this.path(e), t, r);
|
|
3151
3168
|
}
|
|
3152
3169
|
async delete(e) {
|
|
3153
3170
|
await be.rm(this.path(e));
|
|
3154
3171
|
}
|
|
3155
3172
|
}
|
|
3156
|
-
class
|
|
3173
|
+
class Gn {
|
|
3157
3174
|
constructor(e, t, r, n) {
|
|
3158
3175
|
/** Fields are public for tests. */
|
|
3159
3176
|
/** The lock to make sure cache requests are done one by one. */
|
|
3160
|
-
h(this, "lock", new
|
|
3177
|
+
h(this, "lock", new zt.AwaitLock());
|
|
3161
3178
|
h(this, "keyToLastAccessTime", /* @__PURE__ */ new Map());
|
|
3162
3179
|
h(this, "size", 0);
|
|
3163
3180
|
this.logger = e, this.maxSize = t, this.ranges = r, this.storage = n;
|
|
@@ -3186,14 +3203,14 @@ class jn {
|
|
|
3186
3203
|
const e = /* @__PURE__ */ new Date();
|
|
3187
3204
|
for (const t of await this.storage.all()) {
|
|
3188
3205
|
const r = await this.ranges.get(t);
|
|
3189
|
-
this.size +=
|
|
3206
|
+
this.size += H(r), this.keyToLastAccessTime.set(t, e);
|
|
3190
3207
|
}
|
|
3191
3208
|
}
|
|
3192
3209
|
async getUnsafe(e, t) {
|
|
3193
3210
|
if (await this.storage.exists(e)) {
|
|
3194
3211
|
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3195
3212
|
const r = await this.getRanges(e);
|
|
3196
|
-
return
|
|
3213
|
+
return zn(r, t) ? this.storage.path(e) : void 0;
|
|
3197
3214
|
}
|
|
3198
3215
|
}
|
|
3199
3216
|
async setUnsafe(e, t, r) {
|
|
@@ -3207,9 +3224,9 @@ class jn {
|
|
|
3207
3224
|
);
|
|
3208
3225
|
this.keyToLastAccessTime.set(e, /* @__PURE__ */ new Date());
|
|
3209
3226
|
const n = await this.getRanges(e);
|
|
3210
|
-
this.size -=
|
|
3211
|
-
const o =
|
|
3212
|
-
this.size +=
|
|
3227
|
+
this.size -= H(n), await this.storage.write(e, r, t.from);
|
|
3228
|
+
const o = Wn(n, t);
|
|
3229
|
+
this.size += H(o), await this.ranges.set(e, o);
|
|
3213
3230
|
}
|
|
3214
3231
|
/** Ensures the size is less than hard limit by deleting the oldest keys. */
|
|
3215
3232
|
async ensureEvicted() {
|
|
@@ -3219,7 +3236,7 @@ class jn {
|
|
|
3219
3236
|
if (!t)
|
|
3220
3237
|
break;
|
|
3221
3238
|
const [r, n] = t, o = await this.getRanges(r);
|
|
3222
|
-
this.size -=
|
|
3239
|
+
this.size -= H(o), this.rmKey(r);
|
|
3223
3240
|
}
|
|
3224
3241
|
}
|
|
3225
3242
|
/** Gets ranges and if they were corrupted, then remove the file from the cache and reset the cache's size. */
|
|
@@ -3259,8 +3276,8 @@ class pt {
|
|
|
3259
3276
|
h(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3260
3277
|
h(this, "saveDir");
|
|
3261
3278
|
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.rangesCacheDir = o, this.signer = c, this.ops = i, this.cache = new ve(this.ops.cacheSoftSizeBytes);
|
|
3262
|
-
const l = new
|
|
3263
|
-
this.rangesCache = new
|
|
3279
|
+
const l = new Hn(this.logger, this.rangesCacheDir), a = new jn(this.logger, this.rangesCacheDir);
|
|
3280
|
+
this.rangesCache = new Gn(this.logger, this.ops.rangesCacheMaxSizeBytes, l, a), this.downloadQueue = new Y(this.logger, i.nConcurrentDownloads), this.saveDir = T.resolve(n);
|
|
3264
3281
|
}
|
|
3265
3282
|
static async init(e, t, r, n, o, c, i) {
|
|
3266
3283
|
const l = new pt(e, t, r, n, o, c, i);
|
|
@@ -3268,14 +3285,14 @@ class pt {
|
|
|
3268
3285
|
}
|
|
3269
3286
|
getDownloadedBlob(e, t) {
|
|
3270
3287
|
if (t === void 0)
|
|
3271
|
-
return
|
|
3272
|
-
const r = D(e, t), n =
|
|
3288
|
+
return b.make((c) => this.getDownloadedBlob(e, c));
|
|
3289
|
+
const r = D(e, t), n = S();
|
|
3273
3290
|
t.addOnDestroy(() => this.releaseBlob(r, n));
|
|
3274
3291
|
const o = this.getDownloadedBlobNoCtx(t.watcher, r, n);
|
|
3275
3292
|
return o == null && t.markUnstable("download blob is still undefined"), o;
|
|
3276
3293
|
}
|
|
3277
3294
|
getDownloadedBlobNoCtx(e, t, r) {
|
|
3278
|
-
|
|
3295
|
+
F("getDownloadedBlob", t.type);
|
|
3279
3296
|
const n = this.getOrSetNewTask(t, r);
|
|
3280
3297
|
n.attach(e, r);
|
|
3281
3298
|
const o = n.getBlob();
|
|
@@ -3286,14 +3303,14 @@ class pt {
|
|
|
3286
3303
|
}
|
|
3287
3304
|
}
|
|
3288
3305
|
getOrSetNewTask(e, t) {
|
|
3289
|
-
const r =
|
|
3306
|
+
const r = k(e.id), n = this.keyToDownload.get(r);
|
|
3290
3307
|
if (n)
|
|
3291
3308
|
return n;
|
|
3292
|
-
const o =
|
|
3309
|
+
const o = T.resolve(this.saveDir, r), c = new Dn(
|
|
3293
3310
|
this.logger,
|
|
3294
3311
|
this.clientDownload,
|
|
3295
3312
|
e,
|
|
3296
|
-
|
|
3313
|
+
kn(o, this.signer),
|
|
3297
3314
|
o
|
|
3298
3315
|
);
|
|
3299
3316
|
return this.keyToDownload.set(r, c), this.downloadQueue.push({
|
|
@@ -3307,14 +3324,14 @@ class pt {
|
|
|
3307
3324
|
r.done && r.result.ok && this.cache.addCache(e, t);
|
|
3308
3325
|
}
|
|
3309
3326
|
getOnDemandBlob(e, t) {
|
|
3310
|
-
if (t === void 0) return
|
|
3311
|
-
const r =
|
|
3327
|
+
if (t === void 0) return b.make((c) => this.getOnDemandBlob(e, c));
|
|
3328
|
+
const r = M(e) ? J(e, Ln, t) : e, n = S();
|
|
3312
3329
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(r.id, n)), this.getOnDemandBlobNoCtx(r, n);
|
|
3313
3330
|
}
|
|
3314
3331
|
getOnDemandBlobNoCtx(e, t) {
|
|
3315
|
-
|
|
3316
|
-
let r = this.keyToOnDemand.get(
|
|
3317
|
-
return r === void 0 && (r = new
|
|
3332
|
+
F("getOnDemandBlob", e.type);
|
|
3333
|
+
let r = this.keyToOnDemand.get(k(e.id));
|
|
3334
|
+
return r === void 0 && (r = new Vn(ot(e), Rn(e, this.signer)), this.keyToOnDemand.set(k(e.id), r)), r.attach(t), r.getHandle();
|
|
3318
3335
|
}
|
|
3319
3336
|
/** Gets a path from a handle. */
|
|
3320
3337
|
getLocalPath(e) {
|
|
@@ -3323,10 +3340,10 @@ class pt {
|
|
|
3323
3340
|
}
|
|
3324
3341
|
/** Gets a content of a blob by a handle. */
|
|
3325
3342
|
async getContent(e, t) {
|
|
3326
|
-
if (t && Be(t, "getContent"),
|
|
3343
|
+
if (t && Be(t, "getContent"), Tn(e))
|
|
3327
3344
|
return await Ee(this.getLocalPath(e), t);
|
|
3328
|
-
if (
|
|
3329
|
-
const r =
|
|
3345
|
+
if (Nn(e)) {
|
|
3346
|
+
const r = $n(e, this.signer), n = k(r.info.id), o = await this.rangesCache.get(n, t ?? { from: 0, to: r.size });
|
|
3330
3347
|
if (o)
|
|
3331
3348
|
return await Ee(o, t);
|
|
3332
3349
|
const c = await this.clientDownload.withBlobContent(
|
|
@@ -3344,7 +3361,7 @@ class pt {
|
|
|
3344
3361
|
* Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
|
|
3345
3362
|
*/
|
|
3346
3363
|
getComputableContent(e, t) {
|
|
3347
|
-
return t && Be(t, "getComputableContent"),
|
|
3364
|
+
return t && Be(t, "getComputableContent"), b.make(
|
|
3348
3365
|
(r) => this.getDownloadedBlob(e, r),
|
|
3349
3366
|
{
|
|
3350
3367
|
postprocessValue: (r) => r ? this.getContent(r.handle, t) : void 0
|
|
@@ -3352,21 +3369,21 @@ class pt {
|
|
|
3352
3369
|
).withStableType();
|
|
3353
3370
|
}
|
|
3354
3371
|
getLastLogs(e, t, r) {
|
|
3355
|
-
if (r == null) return
|
|
3356
|
-
const n = D(e, r), o =
|
|
3372
|
+
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
3373
|
+
const n = D(e, r), o = S();
|
|
3357
3374
|
r.addOnDestroy(() => this.releaseBlob(n, o));
|
|
3358
3375
|
const c = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
3359
3376
|
return c == null && r.markUnstable("either a file was not downloaded or logs was not read"), c;
|
|
3360
3377
|
}
|
|
3361
3378
|
getLastLogsNoCtx(e, t, r, n) {
|
|
3362
|
-
|
|
3379
|
+
F("getLastLogs", t.type);
|
|
3363
3380
|
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3364
3381
|
if (o == null) return;
|
|
3365
3382
|
const { path: c } = pe(o.handle, this.signer);
|
|
3366
|
-
let i = this.idToLastLines.get(
|
|
3383
|
+
let i = this.idToLastLines.get(k(t.id));
|
|
3367
3384
|
if (i == null) {
|
|
3368
3385
|
const a = new Fe(c, r);
|
|
3369
|
-
this.idToLastLines.set(
|
|
3386
|
+
this.idToLastLines.set(k(t.id), a), i = a;
|
|
3370
3387
|
}
|
|
3371
3388
|
const l = i.getOrSchedule(e);
|
|
3372
3389
|
if (l.error) throw l.error;
|
|
@@ -3374,8 +3391,8 @@ class pt {
|
|
|
3374
3391
|
}
|
|
3375
3392
|
getProgressLog(e, t, r) {
|
|
3376
3393
|
if (r == null)
|
|
3377
|
-
return
|
|
3378
|
-
const n = D(e, r), o =
|
|
3394
|
+
return b.make((i) => this.getProgressLog(e, t, i));
|
|
3395
|
+
const n = D(e, r), o = S();
|
|
3379
3396
|
r.addOnDestroy(() => this.releaseBlob(n, o));
|
|
3380
3397
|
const c = this.getProgressLogNoCtx(
|
|
3381
3398
|
r.watcher,
|
|
@@ -3386,30 +3403,30 @@ class pt {
|
|
|
3386
3403
|
return c === void 0 && r.markUnstable("either a file was not downloaded or a progress log was not read"), c;
|
|
3387
3404
|
}
|
|
3388
3405
|
getProgressLogNoCtx(e, t, r, n) {
|
|
3389
|
-
|
|
3406
|
+
F("getProgressLog", t.type);
|
|
3390
3407
|
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3391
3408
|
if (o == null) return;
|
|
3392
3409
|
const { path: c } = pe(o.handle, this.signer);
|
|
3393
|
-
let i = this.idToProgressLog.get(
|
|
3410
|
+
let i = this.idToProgressLog.get(k(t.id));
|
|
3394
3411
|
if (i == null) {
|
|
3395
3412
|
const a = new Fe(c, 1, r);
|
|
3396
|
-
this.idToProgressLog.set(
|
|
3413
|
+
this.idToProgressLog.set(k(t.id), a), i = a;
|
|
3397
3414
|
}
|
|
3398
3415
|
const l = i.getOrSchedule(e);
|
|
3399
3416
|
if (l.error) throw l.error;
|
|
3400
3417
|
return l.log;
|
|
3401
3418
|
}
|
|
3402
3419
|
getLogHandle(e, t) {
|
|
3403
|
-
if (t == null) return
|
|
3420
|
+
if (t == null) return b.make((n) => this.getLogHandle(e, n));
|
|
3404
3421
|
const r = D(e, t);
|
|
3405
3422
|
return this.getLogHandleNoCtx(r);
|
|
3406
3423
|
}
|
|
3407
3424
|
getLogHandleNoCtx(e) {
|
|
3408
|
-
return
|
|
3425
|
+
return F("getLogHandle", e.type), at(!1, e);
|
|
3409
3426
|
}
|
|
3410
3427
|
async lastLines(e, t, r, n) {
|
|
3411
3428
|
const o = await this.clientLogs.lastLines(
|
|
3412
|
-
|
|
3429
|
+
Q(e),
|
|
3413
3430
|
t,
|
|
3414
3431
|
BigInt(r ?? 0),
|
|
3415
3432
|
n
|
|
@@ -3424,7 +3441,7 @@ class pt {
|
|
|
3424
3441
|
}
|
|
3425
3442
|
async readText(e, t, r, n) {
|
|
3426
3443
|
const o = await this.clientLogs.readText(
|
|
3427
|
-
|
|
3444
|
+
Q(e),
|
|
3428
3445
|
t,
|
|
3429
3446
|
BigInt(r ?? 0),
|
|
3430
3447
|
n
|
|
@@ -3438,39 +3455,39 @@ class pt {
|
|
|
3438
3455
|
};
|
|
3439
3456
|
}
|
|
3440
3457
|
async releaseBlob(e, t) {
|
|
3441
|
-
const r = this.keyToDownload.get(
|
|
3458
|
+
const r = this.keyToDownload.get(k(e.id));
|
|
3442
3459
|
if (r != null)
|
|
3443
|
-
if (this.cache.existsFile(
|
|
3444
|
-
const n = this.cache.removeFile(
|
|
3460
|
+
if (this.cache.existsFile(k(e.id))) {
|
|
3461
|
+
const n = this.cache.removeFile(k(e.id), t);
|
|
3445
3462
|
await Promise.all(
|
|
3446
3463
|
n.map(async (o) => {
|
|
3447
3464
|
await w.rm(o.path), this.cache.removeCache(o), this.removeTask(
|
|
3448
3465
|
me(this.keyToDownload, _e(o.path)),
|
|
3449
|
-
`the task ${
|
|
3466
|
+
`the task ${y(o)} was removedfrom cache along with ${y(n.map((c) => c.path))}`
|
|
3450
3467
|
);
|
|
3451
3468
|
})
|
|
3452
3469
|
);
|
|
3453
3470
|
} else
|
|
3454
3471
|
r.counter.dec(t) && this.removeTask(
|
|
3455
3472
|
r,
|
|
3456
|
-
`the task ${
|
|
3473
|
+
`the task ${y(r.info())} was removed from cache`
|
|
3457
3474
|
);
|
|
3458
3475
|
}
|
|
3459
3476
|
removeTask(e, t) {
|
|
3460
|
-
e.abort(t), e.change.markChanged(`download task for ${e.path} removed: ${t}`), this.keyToDownload.delete(_e(e.path)), this.idToLastLines.delete(
|
|
3477
|
+
e.abort(t), e.change.markChanged(`download task for ${e.path} removed: ${t}`), this.keyToDownload.delete(_e(e.path)), this.idToLastLines.delete(k(e.rInfo.id)), this.idToProgressLog.delete(k(e.rInfo.id));
|
|
3461
3478
|
}
|
|
3462
3479
|
async releaseOnDemandBlob(e, t) {
|
|
3463
3480
|
var n;
|
|
3464
|
-
(((n = this.keyToOnDemand.get(
|
|
3481
|
+
(((n = this.keyToOnDemand.get(k(e))) == null ? void 0 : n.release(t)) ?? !1) && this.keyToOnDemand.delete(k(e));
|
|
3465
3482
|
}
|
|
3466
3483
|
/** Removes all files from a hard drive. */
|
|
3467
3484
|
async releaseAll() {
|
|
3468
3485
|
this.downloadQueue.stop(), this.keyToDownload.forEach((e, t) => {
|
|
3469
|
-
this.keyToDownload.delete(t), e.change.markChanged(`task ${
|
|
3486
|
+
this.keyToDownload.delete(t), e.change.markChanged(`task ${P(e.rInfo.id)} released`);
|
|
3470
3487
|
});
|
|
3471
3488
|
}
|
|
3472
3489
|
}
|
|
3473
|
-
class
|
|
3490
|
+
class Vn {
|
|
3474
3491
|
constructor(e, t) {
|
|
3475
3492
|
h(this, "counter", new B());
|
|
3476
3493
|
this.size = e, this.handle = t;
|
|
@@ -3491,7 +3508,7 @@ class Fe {
|
|
|
3491
3508
|
h(this, "log");
|
|
3492
3509
|
h(this, "change", new C());
|
|
3493
3510
|
h(this, "error");
|
|
3494
|
-
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new
|
|
3511
|
+
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new Sn(async () => this.update());
|
|
3495
3512
|
}
|
|
3496
3513
|
getOrSchedule(e) {
|
|
3497
3514
|
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
@@ -3501,7 +3518,7 @@ class Fe {
|
|
|
3501
3518
|
}
|
|
3502
3519
|
async update() {
|
|
3503
3520
|
try {
|
|
3504
|
-
const e = await
|
|
3521
|
+
const e = await qn(this.path, this.lines, this.patternToSearch);
|
|
3505
3522
|
this.log != e && this.change.markChanged(`logs for ${this.path} updated`), this.log = e;
|
|
3506
3523
|
} catch (e) {
|
|
3507
3524
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
@@ -3512,11 +3529,11 @@ class Fe {
|
|
|
3512
3529
|
}
|
|
3513
3530
|
}
|
|
3514
3531
|
}
|
|
3515
|
-
async function
|
|
3532
|
+
async function qn(s, e, t) {
|
|
3516
3533
|
let r, n;
|
|
3517
3534
|
try {
|
|
3518
|
-
r = Ne.createReadStream(s), n =
|
|
3519
|
-
const o = new
|
|
3535
|
+
r = Ne.createReadStream(s), n = Ot.createInterface({ input: r, crlfDelay: 1 / 0 });
|
|
3536
|
+
const o = new Et();
|
|
3520
3537
|
for await (const c of n)
|
|
3521
3538
|
t != null && !c.includes(t) || (o.push(c), o.length > e && o.shift());
|
|
3522
3539
|
return o.toArray().join(Ce.EOL) + Ce.EOL;
|
|
@@ -3533,45 +3550,45 @@ async function Vn(s, e, t) {
|
|
|
3533
3550
|
}
|
|
3534
3551
|
}
|
|
3535
3552
|
}
|
|
3536
|
-
function
|
|
3553
|
+
function F(s, e) {
|
|
3537
3554
|
if (!e.name.startsWith("Blob/")) {
|
|
3538
3555
|
let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
|
|
3539
3556
|
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Ie(t);
|
|
3540
3557
|
}
|
|
3541
3558
|
}
|
|
3542
|
-
const
|
|
3543
|
-
function
|
|
3544
|
-
const t =
|
|
3545
|
-
return
|
|
3559
|
+
const Jn = ee({});
|
|
3560
|
+
function Zn(s, e) {
|
|
3561
|
+
const t = M(s) ? e.accessor(s).node() : Ze(s) ? s.node() : s;
|
|
3562
|
+
return J(t, Jn);
|
|
3546
3563
|
}
|
|
3547
|
-
function
|
|
3548
|
-
const r =
|
|
3564
|
+
function Qn(s, e, t) {
|
|
3565
|
+
const r = U.relative(e, t);
|
|
3549
3566
|
return `plblob+folder://${s.sign(r)}.${r}.blob`;
|
|
3550
3567
|
}
|
|
3551
|
-
function
|
|
3552
|
-
const r =
|
|
3568
|
+
function Kn(s, e, t) {
|
|
3569
|
+
const r = U.relative(e, t);
|
|
3553
3570
|
return `block-ui://${s.sign(r)}.${r}.uidir`;
|
|
3554
3571
|
}
|
|
3555
|
-
function
|
|
3572
|
+
function Xn(s, e, t) {
|
|
3556
3573
|
return gt(s, e, t);
|
|
3557
3574
|
}
|
|
3558
|
-
function
|
|
3575
|
+
function Yn(s, e, t) {
|
|
3559
3576
|
return gt(s, e, t);
|
|
3560
3577
|
}
|
|
3561
3578
|
function gt(s, e, t) {
|
|
3562
3579
|
const r = new URL(e), [n, o, c] = r.host.split(".");
|
|
3563
3580
|
s.verify(o, n, `signature verification failed for url: ${e}, subfolder: ${o}`);
|
|
3564
3581
|
const i = decodeURIComponent(r.pathname.slice(1));
|
|
3565
|
-
let l =
|
|
3566
|
-
return (r.pathname == "" || r.pathname == "/") && (l =
|
|
3582
|
+
let l = eo(U.join(t, `${o}`), i);
|
|
3583
|
+
return (r.pathname == "" || r.pathname == "/") && (l = U.join(l, "index.html")), U.resolve(l);
|
|
3567
3584
|
}
|
|
3568
|
-
function
|
|
3569
|
-
const t =
|
|
3585
|
+
function eo(s, e) {
|
|
3586
|
+
const t = U.resolve(s, e), r = U.resolve(s);
|
|
3570
3587
|
if (!t.startsWith(r))
|
|
3571
3588
|
throw new Error("Path validation failed.");
|
|
3572
3589
|
return t;
|
|
3573
3590
|
}
|
|
3574
|
-
class
|
|
3591
|
+
class to {
|
|
3575
3592
|
constructor(e, t, r, n, o, c, i) {
|
|
3576
3593
|
h(this, "counter", new B());
|
|
3577
3594
|
h(this, "change", new C());
|
|
@@ -3601,10 +3618,10 @@ class eo {
|
|
|
3601
3618
|
async download() {
|
|
3602
3619
|
try {
|
|
3603
3620
|
const e = await this.downloadAndDecompress(this.signalCtl.signal);
|
|
3604
|
-
this.setDone(e), this.change.markChanged(`download and decompress for ${
|
|
3621
|
+
this.setDone(e), this.change.markChanged(`download and decompress for ${P(this.rInfo.id)} finished`), this.logger.info(`blob to URL task is done: ${y(this.info())}`);
|
|
3605
3622
|
} catch (e) {
|
|
3606
|
-
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${
|
|
3607
|
-
this.setError(e), this.change.markChanged(`download and decompress for ${
|
|
3623
|
+
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${y(this.info())}`), ro(e)) {
|
|
3624
|
+
this.setError(e), this.change.markChanged(`download and decompress for ${P(this.rInfo.id)} failed`), await Te(this.path);
|
|
3608
3625
|
return;
|
|
3609
3626
|
}
|
|
3610
3627
|
throw e;
|
|
@@ -3612,41 +3629,41 @@ class eo {
|
|
|
3612
3629
|
}
|
|
3613
3630
|
/** Does the download part and keeps a state of the process. */
|
|
3614
3631
|
async downloadAndDecompress(e) {
|
|
3615
|
-
return this.state = {}, this.state.parentDir =
|
|
3632
|
+
return this.state = {}, this.state.parentDir = U.dirname(this.path), await W(this.state.parentDir), this.state.fileExisted = await A(this.path), this.state.fileExisted ? await ft(this.path) : await this.clientDownload.withBlobContent(
|
|
3616
3633
|
this.rInfo,
|
|
3617
3634
|
{},
|
|
3618
3635
|
{ signal: e },
|
|
3619
|
-
async (r, n) => (this.state.downloaded = !0, await
|
|
3636
|
+
async (r, n) => (this.state.downloaded = !0, await X(this.logger, this.path, async (o) => {
|
|
3620
3637
|
switch (this.state.tempPath = o, this.state.archiveFormat = this.format, this.format) {
|
|
3621
3638
|
case "tar":
|
|
3622
3639
|
await w.mkdir(o);
|
|
3623
|
-
const c =
|
|
3640
|
+
const c = z.toWeb(ke.extract(o));
|
|
3624
3641
|
await r.pipeTo(c, { signal: e });
|
|
3625
3642
|
return;
|
|
3626
3643
|
case "tgz":
|
|
3627
3644
|
await w.mkdir(o);
|
|
3628
|
-
const i = Ve.toWeb(Qe.createGunzip()), l =
|
|
3645
|
+
const i = Ve.toWeb(Qe.createGunzip()), l = z.toWeb(ke.extract(o));
|
|
3629
3646
|
await r.pipeThrough(i, { signal: e }).pipeTo(l, { signal: e });
|
|
3630
3647
|
return;
|
|
3631
3648
|
case "zip":
|
|
3632
3649
|
this.state.zipPath = this.path + ".zip";
|
|
3633
|
-
const a =
|
|
3634
|
-
await r.pipeTo(a, { signal: e }), this.state.zipPathCreated = !0, await
|
|
3650
|
+
const a = z.toWeb(ye.createWriteStream(this.state.zipPath));
|
|
3651
|
+
await r.pipeTo(a, { signal: e }), this.state.zipPathCreated = !0, await Wt(this.state.zipPath, o, {
|
|
3635
3652
|
filter: (d) => !d.path.endsWith("/")
|
|
3636
3653
|
}), this.state.zipDecompressed = !0, await ye.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
|
|
3637
3654
|
return;
|
|
3638
3655
|
default:
|
|
3639
|
-
|
|
3656
|
+
Nt(this.format);
|
|
3640
3657
|
}
|
|
3641
3658
|
}), this.state.pathCreated = !0, n)
|
|
3642
3659
|
);
|
|
3643
3660
|
}
|
|
3644
3661
|
getURL() {
|
|
3645
|
-
if (this.done) return { url:
|
|
3662
|
+
if (this.done) return { url: K(this.url) };
|
|
3646
3663
|
if (this.error) return { error: this.error };
|
|
3647
3664
|
}
|
|
3648
3665
|
setDone(e) {
|
|
3649
|
-
this.done = !0, this.size = e, this.url =
|
|
3666
|
+
this.done = !0, this.size = e, this.url = Qn(this.signer, this.saveDir, this.path);
|
|
3650
3667
|
}
|
|
3651
3668
|
setError(e) {
|
|
3652
3669
|
this.error = String(e);
|
|
@@ -3659,7 +3676,7 @@ async function ft(s) {
|
|
|
3659
3676
|
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
3660
3677
|
return (await Promise.all(
|
|
3661
3678
|
e.map(async (r) => {
|
|
3662
|
-
const n =
|
|
3679
|
+
const n = U.join(s, r.name);
|
|
3663
3680
|
return r.isDirectory() ? await ft(n) : (await w.stat(n)).size;
|
|
3664
3681
|
})
|
|
3665
3682
|
)).reduce((r, n) => r + n, 0);
|
|
@@ -3673,13 +3690,13 @@ let wt = class extends Error {
|
|
|
3673
3690
|
h(this, "name", "URLAborted");
|
|
3674
3691
|
}
|
|
3675
3692
|
};
|
|
3676
|
-
function
|
|
3677
|
-
return s instanceof wt || s instanceof
|
|
3693
|
+
function ro(s) {
|
|
3694
|
+
return s instanceof wt || s instanceof te || s instanceof Se || s instanceof $e || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
|
|
3678
3695
|
}
|
|
3679
|
-
function
|
|
3696
|
+
function j(s, e) {
|
|
3680
3697
|
return `id:${String(BigInt(s))}-${e}`;
|
|
3681
3698
|
}
|
|
3682
|
-
class
|
|
3699
|
+
class ls {
|
|
3683
3700
|
constructor(e, t, r, n, o = {
|
|
3684
3701
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
3685
3702
|
nConcurrentDownloads: 50
|
|
@@ -3689,7 +3706,7 @@ class as {
|
|
|
3689
3706
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3690
3707
|
* file that should be kept. */
|
|
3691
3708
|
h(this, "cache");
|
|
3692
|
-
this.logger = e, this.signer = t, this.clientDownload = r, this.saveDir = n, this.opts = o, this.downloadQueue = new
|
|
3709
|
+
this.logger = e, this.signer = t, this.clientDownload = r, this.saveDir = n, this.opts = o, this.downloadQueue = new Y(this.logger, this.opts.nConcurrentDownloads, {
|
|
3693
3710
|
type: "exponentialWithMaxDelayBackoff",
|
|
3694
3711
|
initialDelay: 1e4,
|
|
3695
3712
|
maxDelay: 3e4,
|
|
@@ -3710,14 +3727,14 @@ class as {
|
|
|
3710
3727
|
* @returns full path to the referenced file
|
|
3711
3728
|
*/
|
|
3712
3729
|
getPathForCustomProtocol(e) {
|
|
3713
|
-
if (
|
|
3714
|
-
return
|
|
3730
|
+
if (vt(e))
|
|
3731
|
+
return Xn(this.signer, e, this.saveDir);
|
|
3715
3732
|
throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
|
|
3716
3733
|
}
|
|
3717
3734
|
extractArchiveAndGetURL(e, t, r) {
|
|
3718
3735
|
if (r === void 0)
|
|
3719
|
-
return
|
|
3720
|
-
const n =
|
|
3736
|
+
return b.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
3737
|
+
const n = M(e) ? Zn(e, r) : e, o = S();
|
|
3721
3738
|
r.addOnDestroy(() => this.releasePath(n.id, t, o));
|
|
3722
3739
|
const c = this.extractArchiveAndGetURLNoCtx(n, t, r.watcher, o);
|
|
3723
3740
|
if ((c == null ? void 0 : c.url) === void 0 && r.markUnstable(
|
|
@@ -3727,7 +3744,7 @@ class as {
|
|
|
3727
3744
|
return c == null ? void 0 : c.url;
|
|
3728
3745
|
}
|
|
3729
3746
|
extractArchiveAndGetURLNoCtx(e, t, r, n) {
|
|
3730
|
-
const o = this.idToDownload.get(
|
|
3747
|
+
const o = this.idToDownload.get(j(e.id, t));
|
|
3731
3748
|
if (o != null)
|
|
3732
3749
|
return o.attach(r, n), o.getURL();
|
|
3733
3750
|
const c = this.setNewTask(r, e, t, n);
|
|
@@ -3744,7 +3761,7 @@ class as {
|
|
|
3744
3761
|
/** Removes a directory and aborts a downloading task when all callers
|
|
3745
3762
|
* are not interested in it. */
|
|
3746
3763
|
async releasePath(e, t, r) {
|
|
3747
|
-
const n = this.idToDownload.get(
|
|
3764
|
+
const n = this.idToDownload.get(j(e, t));
|
|
3748
3765
|
if (n != null)
|
|
3749
3766
|
if (this.cache.existsFile(n.path)) {
|
|
3750
3767
|
const o = this.cache.removeFile(n.path, r);
|
|
@@ -3752,14 +3769,14 @@ class as {
|
|
|
3752
3769
|
o.map(async (c) => {
|
|
3753
3770
|
await Te(c.path), this.cache.removeCache(c), this.removeTask(
|
|
3754
3771
|
c,
|
|
3755
|
-
`the task ${
|
|
3772
|
+
`the task ${y(c.info())} was removedfrom cache along with ${y(o.map((i) => i.info()))}`
|
|
3756
3773
|
);
|
|
3757
3774
|
})
|
|
3758
3775
|
);
|
|
3759
3776
|
} else
|
|
3760
3777
|
n.counter.dec(r) && this.removeTask(
|
|
3761
3778
|
n,
|
|
3762
|
-
`the task ${
|
|
3779
|
+
`the task ${y(n.info())} was removed from cache`
|
|
3763
3780
|
);
|
|
3764
3781
|
}
|
|
3765
3782
|
/** Removes all files from a hard drive. */
|
|
@@ -3768,13 +3785,13 @@ class as {
|
|
|
3768
3785
|
Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
|
|
3769
3786
|
await Te(t.path), this.cache.removeCache(t), this.removeTask(
|
|
3770
3787
|
t,
|
|
3771
|
-
`the task ${
|
|
3788
|
+
`the task ${y(t.info())} was released when the driver was closed`
|
|
3772
3789
|
);
|
|
3773
3790
|
})
|
|
3774
3791
|
);
|
|
3775
3792
|
}
|
|
3776
3793
|
setNewTask(e, t, r, n) {
|
|
3777
|
-
const o = new
|
|
3794
|
+
const o = new to(
|
|
3778
3795
|
this.logger,
|
|
3779
3796
|
this.signer,
|
|
3780
3797
|
this.saveDir,
|
|
@@ -3783,16 +3800,16 @@ class as {
|
|
|
3783
3800
|
r,
|
|
3784
3801
|
this.clientDownload
|
|
3785
3802
|
);
|
|
3786
|
-
return o.attach(e, n), this.idToDownload.set(
|
|
3803
|
+
return o.attach(e, n), this.idToDownload.set(j(t.id, r), o), o;
|
|
3787
3804
|
}
|
|
3788
3805
|
removeTask(e, t) {
|
|
3789
|
-
e.abort(t), e.change.markChanged(`task for ${
|
|
3806
|
+
e.abort(t), e.change.markChanged(`task for ${P(e.rInfo.id)} removed: ${t}`), this.idToDownload.delete(j(e.rInfo.id, e.format));
|
|
3790
3807
|
}
|
|
3791
3808
|
getFilePath(e, t) {
|
|
3792
|
-
return
|
|
3809
|
+
return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
|
|
3793
3810
|
}
|
|
3794
3811
|
}
|
|
3795
|
-
class
|
|
3812
|
+
class no {
|
|
3796
3813
|
constructor(e, t, r, n, o, c) {
|
|
3797
3814
|
h(this, "change", new C());
|
|
3798
3815
|
h(this, "counter", new B());
|
|
@@ -3809,21 +3826,21 @@ class ro {
|
|
|
3809
3826
|
* At this case, the task will show progress == 1.0. */
|
|
3810
3827
|
h(this, "alreadyExisted", !1);
|
|
3811
3828
|
this.logger = e, this.clientBlob = t, this.clientProgress = r, this.maxNConcurrentPartsUpload = n, this.res = c, this.nMaxUploads = this.maxNConcurrentPartsUpload;
|
|
3812
|
-
const { uploadData: i, progress: l } =
|
|
3829
|
+
const { uploadData: i, progress: l } = so(c, o);
|
|
3813
3830
|
this.uploadData = i, this.progress = l;
|
|
3814
3831
|
}
|
|
3815
3832
|
getProgress(e, t) {
|
|
3816
3833
|
if (this.incCounter(e, t), this.failed)
|
|
3817
3834
|
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3818
|
-
return
|
|
3835
|
+
return ao(this.progress);
|
|
3819
3836
|
}
|
|
3820
3837
|
shouldScheduleUpload() {
|
|
3821
|
-
return
|
|
3838
|
+
return io(this.progress);
|
|
3822
3839
|
}
|
|
3823
3840
|
/** Uploads a blob if it's not BlobIndex. */
|
|
3824
3841
|
async uploadBlobTask() {
|
|
3825
3842
|
try {
|
|
3826
|
-
await
|
|
3843
|
+
await oo(
|
|
3827
3844
|
this.logger,
|
|
3828
3845
|
this.clientBlob,
|
|
3829
3846
|
this.res,
|
|
@@ -3835,24 +3852,24 @@ class ro {
|
|
|
3835
3852
|
currentSpeed: this.nMaxUploads,
|
|
3836
3853
|
maxSpeed: this.maxNConcurrentPartsUpload
|
|
3837
3854
|
}
|
|
3838
|
-
), this.change.markChanged(`blob upload for ${
|
|
3855
|
+
), this.change.markChanged(`blob upload for ${P(this.res.id)} finished`);
|
|
3839
3856
|
} catch (e) {
|
|
3840
3857
|
if (this.setRetriableError(e), Oe(e)) {
|
|
3841
|
-
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${
|
|
3858
|
+
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${P(this.res.id)} aborted, resource was deleted`), this.setDone(!0);
|
|
3842
3859
|
return;
|
|
3843
3860
|
}
|
|
3844
|
-
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${
|
|
3861
|
+
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(`blob upload for ${P(this.res.id)} failed`), mt(e)) {
|
|
3845
3862
|
this.setTerminalError(e);
|
|
3846
3863
|
return;
|
|
3847
3864
|
}
|
|
3848
|
-
throw
|
|
3865
|
+
throw po(e) && (this.nMaxUploads = fo(this.logger, this.nMaxUploads, 1)), e;
|
|
3849
3866
|
}
|
|
3850
3867
|
}
|
|
3851
3868
|
async updateStatus() {
|
|
3852
3869
|
var e;
|
|
3853
3870
|
try {
|
|
3854
|
-
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), r = this.progress.status, n =
|
|
3855
|
-
this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (r == null ? void 0 : r.progress)) && this.change.markChanged(`upload status for ${
|
|
3871
|
+
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), r = this.progress.status, n = uo(this.alreadyExisted, ho(t));
|
|
3872
|
+
this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (r == null ? void 0 : r.progress)) && this.change.markChanged(`upload status for ${P(this.res.id)} changed`);
|
|
3856
3873
|
} catch (t) {
|
|
3857
3874
|
if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
|
|
3858
3875
|
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
@@ -3860,8 +3877,8 @@ class ro {
|
|
|
3860
3877
|
}
|
|
3861
3878
|
if (Oe(t)) {
|
|
3862
3879
|
this.logger.warn(
|
|
3863
|
-
`resource was not found while updating a status of BlobImport: ${t}, ${
|
|
3864
|
-
), this.change.markChanged(`upload status for ${
|
|
3880
|
+
`resource was not found while updating a status of BlobImport: ${t}, ${y(this.res)}`
|
|
3881
|
+
), this.change.markChanged(`upload status for ${P(this.res.id)} changed, resource not found`), this.setDone(!0);
|
|
3865
3882
|
return;
|
|
3866
3883
|
}
|
|
3867
3884
|
this.logger.error(`retryable error while updating a status of BlobImport: ${t}`);
|
|
@@ -3876,7 +3893,7 @@ class ro {
|
|
|
3876
3893
|
this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
|
|
3877
3894
|
}
|
|
3878
3895
|
setDoneIfOutputSet(e) {
|
|
3879
|
-
|
|
3896
|
+
lo(e) && (this.setDone(!0), this.alreadyExisted = !0);
|
|
3880
3897
|
}
|
|
3881
3898
|
setDone(e) {
|
|
3882
3899
|
this.progress.done = e, e && (this.progress.lastError = void 0);
|
|
@@ -3891,8 +3908,8 @@ class ro {
|
|
|
3891
3908
|
return this.counter.isZero();
|
|
3892
3909
|
}
|
|
3893
3910
|
}
|
|
3894
|
-
async function
|
|
3895
|
-
|
|
3911
|
+
async function oo(s, e, t, r, n, o) {
|
|
3912
|
+
xt(Le(t), "the upload operation can be done only for BlobUploads");
|
|
3896
3913
|
const c = 1e4;
|
|
3897
3914
|
if (n()) return;
|
|
3898
3915
|
const i = await e.initUpload(t, { timeout: c });
|
|
@@ -3906,13 +3923,13 @@ async function no(s, e, t, r, n, o) {
|
|
|
3906
3923
|
BigInt(r.modificationTime),
|
|
3907
3924
|
a,
|
|
3908
3925
|
{ timeout: c }
|
|
3909
|
-
), s.info(`uploaded chunk ${a}/${i.overall} of resource: ${t.id}`), o.nPartsWithThisUploadSpeed++, o.nPartsWithThisUploadSpeed >= o.nPartsToIncreaseUpload && (o.nPartsWithThisUploadSpeed = 0, o.currentSpeed =
|
|
3926
|
+
), s.info(`uploaded chunk ${a}/${i.overall} of resource: ${t.id}`), o.nPartsWithThisUploadSpeed++, o.nPartsWithThisUploadSpeed >= o.nPartsToIncreaseUpload && (o.nPartsWithThisUploadSpeed = 0, o.currentSpeed = go(s, o.currentSpeed, o.maxSpeed), d.setConcurrency(o.currentSpeed)));
|
|
3910
3927
|
};
|
|
3911
3928
|
await Re(o.currentSpeed, i.toUpload.map(l)), !n() && (await e.finalize(t, { timeout: c }), s.info(`uploading of resource ${t.id} finished.`));
|
|
3912
3929
|
}
|
|
3913
|
-
function
|
|
3930
|
+
function so(s, e) {
|
|
3914
3931
|
let t, r;
|
|
3915
|
-
return Le(s) && (r =
|
|
3932
|
+
return Le(s) && (r = re.parse(s.data), t = co(e, r.localPath, r.pathSignature)), {
|
|
3916
3933
|
uploadData: r,
|
|
3917
3934
|
progress: {
|
|
3918
3935
|
done: !1,
|
|
@@ -3923,33 +3940,33 @@ function oo(s, e) {
|
|
|
3923
3940
|
}
|
|
3924
3941
|
};
|
|
3925
3942
|
}
|
|
3926
|
-
function
|
|
3943
|
+
function io(s) {
|
|
3927
3944
|
return s.isUpload && (s.isUploadSignMatch ?? !1);
|
|
3928
3945
|
}
|
|
3929
|
-
function
|
|
3946
|
+
function ao(s) {
|
|
3930
3947
|
return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
|
|
3931
3948
|
}
|
|
3932
|
-
function
|
|
3949
|
+
function lo(s) {
|
|
3933
3950
|
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
3934
3951
|
}
|
|
3935
3952
|
function Le(s) {
|
|
3936
3953
|
return s.type.name.startsWith("BlobUpload");
|
|
3937
3954
|
}
|
|
3938
|
-
function
|
|
3955
|
+
function co(s, e, t) {
|
|
3939
3956
|
try {
|
|
3940
3957
|
return s.verify(e, t), !0;
|
|
3941
3958
|
} catch {
|
|
3942
3959
|
return !1;
|
|
3943
3960
|
}
|
|
3944
3961
|
}
|
|
3945
|
-
function
|
|
3962
|
+
function ho(s) {
|
|
3946
3963
|
return {
|
|
3947
3964
|
progress: s.progress ?? 0,
|
|
3948
3965
|
bytesProcessed: Number(s.bytesProcessed),
|
|
3949
3966
|
bytesTotal: Number(s.bytesTotal)
|
|
3950
3967
|
};
|
|
3951
3968
|
}
|
|
3952
|
-
function
|
|
3969
|
+
function uo(s, e) {
|
|
3953
3970
|
return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
|
|
3954
3971
|
progress: 1,
|
|
3955
3972
|
bytesProcessed: Number(e.bytesTotal),
|
|
@@ -3962,22 +3979,22 @@ function Oe(s) {
|
|
|
3962
3979
|
function mt(s) {
|
|
3963
3980
|
return s instanceof Xe || s instanceof Ye || s instanceof tt;
|
|
3964
3981
|
}
|
|
3965
|
-
function
|
|
3982
|
+
function po(s) {
|
|
3966
3983
|
return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
|
|
3967
3984
|
}
|
|
3968
|
-
function
|
|
3985
|
+
function go(s, e, t) {
|
|
3969
3986
|
const r = Math.min(e + 2, t);
|
|
3970
3987
|
return r != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${r}`), r;
|
|
3971
3988
|
}
|
|
3972
|
-
function
|
|
3989
|
+
function fo(s, e, t) {
|
|
3973
3990
|
const r = Math.max(Math.round(e / 2), t);
|
|
3974
3991
|
return r != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${r}`), r;
|
|
3975
3992
|
}
|
|
3976
|
-
function
|
|
3977
|
-
const t =
|
|
3978
|
-
return t.resourceType.name.startsWith("BlobUpload") ?
|
|
3993
|
+
function wo(s, e) {
|
|
3994
|
+
const t = M(s) ? e.accessor(s).node() : Ze(s) ? s.node() : s;
|
|
3995
|
+
return t.resourceType.name.startsWith("BlobUpload") ? J(t, Un) : J(t, Pn);
|
|
3979
3996
|
}
|
|
3980
|
-
class
|
|
3997
|
+
class cs {
|
|
3981
3998
|
constructor(e, t, r, n, o = {
|
|
3982
3999
|
nConcurrentPartUploads: 10,
|
|
3983
4000
|
nConcurrentGetProgresses: 10,
|
|
@@ -3993,7 +4010,7 @@ class ls {
|
|
|
3993
4010
|
h(this, "keepRunning", !1);
|
|
3994
4011
|
/** Actual state of main loop. */
|
|
3995
4012
|
h(this, "currentLoop");
|
|
3996
|
-
this.logger = e, this.signer = t, this.clientBlob = r, this.clientProgress = n, this.opts = o, this.uploadQueue = new
|
|
4013
|
+
this.logger = e, this.signer = t, this.clientBlob = r, this.clientProgress = n, this.opts = o, this.uploadQueue = new Y(this.logger, 1, {
|
|
3997
4014
|
type: "exponentialWithMaxDelayBackoff",
|
|
3998
4015
|
initialDelay: 20,
|
|
3999
4016
|
maxDelay: 15e3,
|
|
@@ -4008,16 +4025,16 @@ class ls {
|
|
|
4008
4025
|
);
|
|
4009
4026
|
}
|
|
4010
4027
|
getProgressId(e, t) {
|
|
4011
|
-
if (t == null) return
|
|
4012
|
-
const r =
|
|
4028
|
+
if (t == null) return b.make((c) => this.getProgressId(e, c));
|
|
4029
|
+
const r = M(e) ? wo(e, t) : e, n = S();
|
|
4013
4030
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(r.id, n)), this.getProgressIdNoCtx(t.watcher, r, n);
|
|
4014
4031
|
}
|
|
4015
4032
|
getProgressIdNoCtx(e, t, r) {
|
|
4016
|
-
|
|
4033
|
+
yo("getProgressId", t.type);
|
|
4017
4034
|
const n = this.idToProgress.get(t.id);
|
|
4018
4035
|
if (n != null)
|
|
4019
4036
|
return n.setDoneIfOutputSet(t), n.getProgress(e, r);
|
|
4020
|
-
const o = new
|
|
4037
|
+
const o = new no(
|
|
4021
4038
|
this.logger,
|
|
4022
4039
|
this.clientBlob,
|
|
4023
4040
|
this.clientProgress,
|
|
@@ -4069,20 +4086,20 @@ class ls {
|
|
|
4069
4086
|
this.currentLoop = void 0;
|
|
4070
4087
|
}
|
|
4071
4088
|
getAllNotDoneProgresses() {
|
|
4072
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !
|
|
4089
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !mo(t.progress)).map(([e, t]) => t);
|
|
4073
4090
|
}
|
|
4074
4091
|
}
|
|
4075
|
-
function
|
|
4092
|
+
function mo(s) {
|
|
4076
4093
|
var e;
|
|
4077
4094
|
return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
|
|
4078
4095
|
}
|
|
4079
|
-
function
|
|
4096
|
+
function yo(s, e) {
|
|
4080
4097
|
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
4081
4098
|
throw new Ie(
|
|
4082
4099
|
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
4083
4100
|
);
|
|
4084
4101
|
}
|
|
4085
|
-
class
|
|
4102
|
+
class hs {
|
|
4086
4103
|
constructor(e, t, r = {
|
|
4087
4104
|
nConcurrentGetLogs: 10,
|
|
4088
4105
|
pollingInterval: 1e3,
|
|
@@ -4107,8 +4124,8 @@ class cs {
|
|
|
4107
4124
|
);
|
|
4108
4125
|
}
|
|
4109
4126
|
getLastLogs(e, t, r) {
|
|
4110
|
-
if (r == null) return
|
|
4111
|
-
const n = D(e, r), o =
|
|
4127
|
+
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
4128
|
+
const n = D(e, r), o = S();
|
|
4112
4129
|
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseLastLogs(n.id, o));
|
|
4113
4130
|
const c = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
4114
4131
|
return r.markUnstable(
|
|
@@ -4129,8 +4146,8 @@ class cs {
|
|
|
4129
4146
|
}
|
|
4130
4147
|
getProgressLog(e, t, r) {
|
|
4131
4148
|
if (r == null)
|
|
4132
|
-
return
|
|
4133
|
-
const n = D(e, r), o =
|
|
4149
|
+
return b.make((i) => this.getProgressLog(e, t, i));
|
|
4150
|
+
const n = D(e, r), o = S();
|
|
4134
4151
|
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseProgressLog(n.id, o));
|
|
4135
4152
|
const c = this.getProgressLogNoCtx(r.watcher, n, t, o);
|
|
4136
4153
|
return r.markUnstable(
|
|
@@ -4150,9 +4167,9 @@ class cs {
|
|
|
4150
4167
|
return c.log;
|
|
4151
4168
|
}
|
|
4152
4169
|
getLogHandle(e, t) {
|
|
4153
|
-
if (t == null) return
|
|
4170
|
+
if (t == null) return b.make((o) => this.getLogHandle(e, o));
|
|
4154
4171
|
const r = D(e, t), n = this.getLogHandleNoCtx(r);
|
|
4155
|
-
return t.markUnstable(`live_log:${
|
|
4172
|
+
return t.markUnstable(`live_log:${P(r.id)}`), n;
|
|
4156
4173
|
}
|
|
4157
4174
|
getLogHandleNoCtx(e) {
|
|
4158
4175
|
return fe("getLogHandle", e.type), at(!0, e);
|
|
@@ -4161,7 +4178,7 @@ class cs {
|
|
|
4161
4178
|
return await this.tryWithNotFound(
|
|
4162
4179
|
e,
|
|
4163
4180
|
() => this.clientLogs.lastLines(
|
|
4164
|
-
|
|
4181
|
+
Q(e),
|
|
4165
4182
|
t,
|
|
4166
4183
|
BigInt(r ?? 0),
|
|
4167
4184
|
n
|
|
@@ -4172,7 +4189,7 @@ class cs {
|
|
|
4172
4189
|
return await this.tryWithNotFound(
|
|
4173
4190
|
e,
|
|
4174
4191
|
() => this.clientLogs.readText(
|
|
4175
|
-
|
|
4192
|
+
Q(e),
|
|
4176
4193
|
t,
|
|
4177
4194
|
BigInt(r ?? 0),
|
|
4178
4195
|
n
|
|
@@ -4180,7 +4197,7 @@ class cs {
|
|
|
4180
4197
|
);
|
|
4181
4198
|
}
|
|
4182
4199
|
async tryWithNotFound(e, t) {
|
|
4183
|
-
if (!
|
|
4200
|
+
if (!Z(e))
|
|
4184
4201
|
throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
|
|
4185
4202
|
try {
|
|
4186
4203
|
const r = await t();
|
|
@@ -4268,7 +4285,7 @@ class ze {
|
|
|
4268
4285
|
0n,
|
|
4269
4286
|
this.patternToSearch
|
|
4270
4287
|
), t = new TextDecoder().decode(e.data);
|
|
4271
|
-
this.logs != t && this.change.markChanged(`logs for ${
|
|
4288
|
+
this.logs != t && this.change.markChanged(`logs for ${P(this.rInfo.id)} updated`), this.logs = t, this.error = void 0;
|
|
4272
4289
|
return;
|
|
4273
4290
|
} catch (e) {
|
|
4274
4291
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
@@ -4276,7 +4293,7 @@ class ze {
|
|
|
4276
4293
|
return;
|
|
4277
4294
|
}
|
|
4278
4295
|
throw this.logger.error(
|
|
4279
|
-
`Stream log lines for ${
|
|
4296
|
+
`Stream log lines for ${y(this.rInfo.id)} failed, reason: ${e}`
|
|
4280
4297
|
), e;
|
|
4281
4298
|
}
|
|
4282
4299
|
}
|
|
@@ -4287,18 +4304,18 @@ function fe(s, e) {
|
|
|
4287
4304
|
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4288
4305
|
);
|
|
4289
4306
|
}
|
|
4290
|
-
class
|
|
4307
|
+
class ds {
|
|
4291
4308
|
constructor(e, t, r) {
|
|
4292
4309
|
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = r;
|
|
4293
4310
|
}
|
|
4294
4311
|
getLastLogs(e, t, r) {
|
|
4295
|
-
if (r === void 0) return
|
|
4296
|
-
const n =
|
|
4312
|
+
if (r === void 0) return b.make((o) => this.getLastLogs(e, t, o));
|
|
4313
|
+
const n = V(r, e);
|
|
4297
4314
|
if (n === void 0) {
|
|
4298
4315
|
r.markUnstable("no stream in stream manager");
|
|
4299
4316
|
return;
|
|
4300
4317
|
}
|
|
4301
|
-
if (
|
|
4318
|
+
if (G(n)) return this.downloadDriver.getLastLogs(n, t, r);
|
|
4302
4319
|
try {
|
|
4303
4320
|
return this.logsStreamDriver.getLastLogs(n, t, r);
|
|
4304
4321
|
} catch (o) {
|
|
@@ -4311,13 +4328,13 @@ class hs {
|
|
|
4311
4328
|
}
|
|
4312
4329
|
getProgressLog(e, t, r) {
|
|
4313
4330
|
if (r === void 0)
|
|
4314
|
-
return
|
|
4315
|
-
const n =
|
|
4331
|
+
return b.make((o) => this.getProgressLog(e, t, o));
|
|
4332
|
+
const n = V(r, e);
|
|
4316
4333
|
if (n === void 0) {
|
|
4317
4334
|
r.markUnstable("no stream in stream manager");
|
|
4318
4335
|
return;
|
|
4319
4336
|
}
|
|
4320
|
-
if (
|
|
4337
|
+
if (G(n)) return this.downloadDriver.getProgressLog(n, t, r);
|
|
4321
4338
|
try {
|
|
4322
4339
|
return this.logsStreamDriver.getProgressLog(n, t, r);
|
|
4323
4340
|
} catch (o) {
|
|
@@ -4330,13 +4347,13 @@ class hs {
|
|
|
4330
4347
|
}
|
|
4331
4348
|
getProgressLogWithInfo(e, t, r) {
|
|
4332
4349
|
if (r === void 0)
|
|
4333
|
-
return
|
|
4334
|
-
const n =
|
|
4350
|
+
return b.make((o) => this.getProgressLogWithInfo(e, t, o));
|
|
4351
|
+
const n = V(r, e);
|
|
4335
4352
|
if (n === void 0) {
|
|
4336
4353
|
r.markUnstable("no stream in stream manager");
|
|
4337
4354
|
return;
|
|
4338
4355
|
}
|
|
4339
|
-
if (
|
|
4356
|
+
if (G(n))
|
|
4340
4357
|
return {
|
|
4341
4358
|
progressLine: this.downloadDriver.getProgressLog(n, t, r),
|
|
4342
4359
|
live: !1
|
|
@@ -4355,29 +4372,29 @@ class hs {
|
|
|
4355
4372
|
}
|
|
4356
4373
|
}
|
|
4357
4374
|
getLogHandle(e, t) {
|
|
4358
|
-
if (t === void 0) return
|
|
4359
|
-
const r =
|
|
4375
|
+
if (t === void 0) return b.make((n) => this.getLogHandle(e, n));
|
|
4376
|
+
const r = V(t, e);
|
|
4360
4377
|
if (r === void 0) {
|
|
4361
4378
|
t.markUnstable("no stream in stream manager");
|
|
4362
4379
|
return;
|
|
4363
4380
|
}
|
|
4364
|
-
return
|
|
4381
|
+
return G(r) ? this.downloadDriver.getLogHandle(r, t) : this.logsStreamDriver.getLogHandle(r, t);
|
|
4365
4382
|
}
|
|
4366
4383
|
async lastLines(e, t, r, n) {
|
|
4367
|
-
return
|
|
4384
|
+
return Z(e) ? await this.logsStreamDriver.lastLines(e, t, r, n) : await this.downloadDriver.lastLines(e, t, r, n);
|
|
4368
4385
|
}
|
|
4369
4386
|
async readText(e, t, r, n) {
|
|
4370
|
-
return
|
|
4387
|
+
return Z(e) ? await this.logsStreamDriver.readText(e, t, r, n) : await this.downloadDriver.readText(e, t, r, n);
|
|
4371
4388
|
}
|
|
4372
4389
|
}
|
|
4373
|
-
function
|
|
4390
|
+
function G(s) {
|
|
4374
4391
|
return !s.type.name.startsWith("StreamWorkdir");
|
|
4375
4392
|
}
|
|
4376
|
-
function
|
|
4393
|
+
function V(s, e) {
|
|
4377
4394
|
var t;
|
|
4378
4395
|
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4379
4396
|
}
|
|
4380
|
-
class
|
|
4397
|
+
class bo {
|
|
4381
4398
|
constructor(e, t, r, n, o) {
|
|
4382
4399
|
h(this, "counter", new B());
|
|
4383
4400
|
h(this, "change", new C());
|
|
@@ -4404,7 +4421,7 @@ class yo {
|
|
|
4404
4421
|
const r = await this.downloadAndUntar(e, t, this.signalCtl.signal);
|
|
4405
4422
|
this.setDone(r), this.change.markChanged(`download of ${this.url} finished`);
|
|
4406
4423
|
} catch (r) {
|
|
4407
|
-
if (r instanceof We || r instanceof
|
|
4424
|
+
if (r instanceof We || r instanceof te) {
|
|
4408
4425
|
this.setError(r), this.change.markChanged(`download of ${this.url} failed`), await Ue(this.path);
|
|
4409
4426
|
return;
|
|
4410
4427
|
}
|
|
@@ -4412,7 +4429,7 @@ class yo {
|
|
|
4412
4429
|
}
|
|
4413
4430
|
}
|
|
4414
4431
|
async downloadAndUntar(e, t, r) {
|
|
4415
|
-
return await
|
|
4432
|
+
return await W(T.dirname(this.path)), await A(this.path) ? await yt(this.path) : await e.withContent(
|
|
4416
4433
|
this.url.toString(),
|
|
4417
4434
|
{},
|
|
4418
4435
|
{ signal: r },
|
|
@@ -4422,9 +4439,9 @@ class yo {
|
|
|
4422
4439
|
const l = Ve.toWeb(Qe.createGunzip());
|
|
4423
4440
|
i = o.pipeThrough(l, { signal: r });
|
|
4424
4441
|
}
|
|
4425
|
-
return await
|
|
4442
|
+
return await X(this.logger, this.path, async (l) => {
|
|
4426
4443
|
await w.mkdir(l);
|
|
4427
|
-
const a =
|
|
4444
|
+
const a = z.toWeb(ke.extract(l));
|
|
4428
4445
|
await i.pipeTo(a, { signal: r });
|
|
4429
4446
|
}), c;
|
|
4430
4447
|
}
|
|
@@ -4432,7 +4449,7 @@ class yo {
|
|
|
4432
4449
|
}
|
|
4433
4450
|
getUrl() {
|
|
4434
4451
|
if (this.done) return {
|
|
4435
|
-
url:
|
|
4452
|
+
url: Kn(this.signer, this.saveDir, K(this.path))
|
|
4436
4453
|
};
|
|
4437
4454
|
if (this.error) return { error: this.error };
|
|
4438
4455
|
}
|
|
@@ -4456,7 +4473,7 @@ async function yt(s) {
|
|
|
4456
4473
|
const e = await w.readdir(s, { withFileTypes: !0 });
|
|
4457
4474
|
return (await Promise.all(
|
|
4458
4475
|
e.map(async (r) => {
|
|
4459
|
-
const n =
|
|
4476
|
+
const n = T.join(s, r.name);
|
|
4460
4477
|
return r.isDirectory() ? await yt(n) : (await w.stat(n)).size;
|
|
4461
4478
|
})
|
|
4462
4479
|
)).reduce((r, n) => r + n, 0);
|
|
@@ -4464,7 +4481,7 @@ async function yt(s) {
|
|
|
4464
4481
|
async function Ue(s) {
|
|
4465
4482
|
await w.rm(s, { recursive: !0, force: !0 });
|
|
4466
4483
|
}
|
|
4467
|
-
class
|
|
4484
|
+
class us {
|
|
4468
4485
|
constructor(e, t, r, n, o = {
|
|
4469
4486
|
cacheSoftSizeBytes: 1 * 1024 * 1024 * 1024,
|
|
4470
4487
|
// 1 GB
|
|
@@ -4477,12 +4494,12 @@ class ds {
|
|
|
4477
4494
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4478
4495
|
* file that should be kept. */
|
|
4479
4496
|
h(this, "cache");
|
|
4480
|
-
this.logger = e, this.saveDir = r, this.signer = n, this.opts = o, this.downloadQueue = new
|
|
4497
|
+
this.logger = e, this.saveDir = r, this.signer = n, this.opts = o, this.downloadQueue = new Y(this.logger, this.opts.nConcurrentDownloads), this.cache = new ve(this.opts.cacheSoftSizeBytes), this.downloadHelper = new rt(t);
|
|
4481
4498
|
}
|
|
4482
4499
|
/** Returns a computable that returns a custom protocol URL to the downloaded and unarchived path. */
|
|
4483
4500
|
getUrl(e, t) {
|
|
4484
|
-
if (t === void 0) return
|
|
4485
|
-
const r =
|
|
4501
|
+
if (t === void 0) return b.make((o) => this.getUrl(e, o));
|
|
4502
|
+
const r = S();
|
|
4486
4503
|
t.addOnDestroy(() => this.releasePath(e, r));
|
|
4487
4504
|
const n = this.getUrlNoCtx(e, t.watcher, r);
|
|
4488
4505
|
return (n == null ? void 0 : n.url) === void 0 && t.markUnstable(
|
|
@@ -4500,9 +4517,9 @@ class ds {
|
|
|
4500
4517
|
}), c.getUrl();
|
|
4501
4518
|
}
|
|
4502
4519
|
getPathForBlockUI(e) {
|
|
4503
|
-
if (!
|
|
4520
|
+
if (!Bt(e))
|
|
4504
4521
|
throw new Error(`getPathForBlockUI: ${e} is invalid`);
|
|
4505
|
-
return
|
|
4522
|
+
return Yn(this.signer, e, this.saveDir);
|
|
4506
4523
|
}
|
|
4507
4524
|
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
4508
4525
|
async downloadUrl(e, t) {
|
|
@@ -4520,14 +4537,14 @@ class ds {
|
|
|
4520
4537
|
o.map(async (c) => {
|
|
4521
4538
|
await Ue(c.path), this.cache.removeCache(c), this.removeTask(
|
|
4522
4539
|
c,
|
|
4523
|
-
`the task ${
|
|
4540
|
+
`the task ${y(c.info())} was removedfrom cache along with ${y(o.map((i) => i.info()))}`
|
|
4524
4541
|
);
|
|
4525
4542
|
})
|
|
4526
4543
|
);
|
|
4527
4544
|
} else
|
|
4528
4545
|
n.counter.dec(t) && this.removeTask(
|
|
4529
4546
|
n,
|
|
4530
|
-
`the task ${
|
|
4547
|
+
`the task ${y(n.info())} was removed from cache`
|
|
4531
4548
|
);
|
|
4532
4549
|
}
|
|
4533
4550
|
/** Removes all files from a hard drive. */
|
|
@@ -4536,13 +4553,13 @@ class ds {
|
|
|
4536
4553
|
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4537
4554
|
await Ue(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4538
4555
|
t,
|
|
4539
|
-
`the task ${
|
|
4556
|
+
`the task ${y(t.info())} was released when the driver was closed`
|
|
4540
4557
|
);
|
|
4541
4558
|
})
|
|
4542
4559
|
);
|
|
4543
4560
|
}
|
|
4544
4561
|
setNewTask(e, t, r) {
|
|
4545
|
-
const n = new
|
|
4562
|
+
const n = new bo(
|
|
4546
4563
|
this.logger,
|
|
4547
4564
|
this.getFilePath(t),
|
|
4548
4565
|
t,
|
|
@@ -4555,8 +4572,8 @@ class ds {
|
|
|
4555
4572
|
e.abort(t), e.change.markChanged(`task for url ${e.url} removed: ${t}`), this.urlToDownload.delete(e.url.toString());
|
|
4556
4573
|
}
|
|
4557
4574
|
getFilePath(e) {
|
|
4558
|
-
const t =
|
|
4559
|
-
return
|
|
4575
|
+
const t = _t("sha256").update(e.toString()).digest("hex");
|
|
4576
|
+
return T.join(this.saveDir, t);
|
|
4560
4577
|
}
|
|
4561
4578
|
}
|
|
4562
4579
|
function we(s, e) {
|
|
@@ -4565,7 +4582,7 @@ function we(s, e) {
|
|
|
4565
4582
|
path: e
|
|
4566
4583
|
}))}`;
|
|
4567
4584
|
}
|
|
4568
|
-
function
|
|
4585
|
+
function ko(s, e, t, r) {
|
|
4569
4586
|
const n = {
|
|
4570
4587
|
localPath: s,
|
|
4571
4588
|
pathSignature: e.sign(s),
|
|
@@ -4574,31 +4591,31 @@ function bo(s, e, t, r) {
|
|
|
4574
4591
|
};
|
|
4575
4592
|
return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
|
|
4576
4593
|
}
|
|
4577
|
-
function
|
|
4594
|
+
function To(s) {
|
|
4578
4595
|
const e = new URL(s);
|
|
4579
|
-
return
|
|
4596
|
+
return re.parse(
|
|
4580
4597
|
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4581
4598
|
);
|
|
4582
4599
|
}
|
|
4583
|
-
function
|
|
4600
|
+
function Lo(s) {
|
|
4584
4601
|
const e = new URL(s);
|
|
4585
4602
|
return st.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4586
4603
|
}
|
|
4587
4604
|
function xe(s) {
|
|
4588
|
-
if (
|
|
4589
|
-
return
|
|
4590
|
-
if (
|
|
4591
|
-
return
|
|
4592
|
-
|
|
4605
|
+
if (No(s))
|
|
4606
|
+
return So(s);
|
|
4607
|
+
if (Uo(s))
|
|
4608
|
+
return Ro(s);
|
|
4609
|
+
St(s);
|
|
4593
4610
|
}
|
|
4594
4611
|
const bt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4595
|
-
function
|
|
4612
|
+
function Uo(s) {
|
|
4596
4613
|
return bt.test(s);
|
|
4597
4614
|
}
|
|
4598
|
-
function
|
|
4615
|
+
function Po(s, e) {
|
|
4599
4616
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4600
4617
|
}
|
|
4601
|
-
function
|
|
4618
|
+
function Ro(s) {
|
|
4602
4619
|
const e = s.match(bt);
|
|
4603
4620
|
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4604
4621
|
const { name: t, path: r } = e.groups;
|
|
@@ -4609,29 +4626,29 @@ function Po(s) {
|
|
|
4609
4626
|
};
|
|
4610
4627
|
}
|
|
4611
4628
|
const kt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4612
|
-
function
|
|
4629
|
+
function No(s) {
|
|
4613
4630
|
return kt.test(s);
|
|
4614
4631
|
}
|
|
4615
|
-
function
|
|
4632
|
+
function $o(s, e) {
|
|
4616
4633
|
return `remote://${s}/${BigInt(e)}`;
|
|
4617
4634
|
}
|
|
4618
|
-
function
|
|
4635
|
+
function So(s) {
|
|
4619
4636
|
const e = s.match(kt);
|
|
4620
4637
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4621
4638
|
const { name: t, resourceId: r } = e.groups;
|
|
4622
4639
|
return {
|
|
4623
4640
|
id: Pe(BigInt(r)),
|
|
4624
|
-
type:
|
|
4641
|
+
type: Io(t),
|
|
4625
4642
|
name: t,
|
|
4626
4643
|
isRemote: !0
|
|
4627
4644
|
};
|
|
4628
4645
|
}
|
|
4629
|
-
function
|
|
4646
|
+
function Io(s) {
|
|
4630
4647
|
return { name: `LS/${s}`, version: "1" };
|
|
4631
4648
|
}
|
|
4632
|
-
async function
|
|
4633
|
-
const s =
|
|
4634
|
-
if (
|
|
4649
|
+
async function Do() {
|
|
4650
|
+
const s = Ft.homedir();
|
|
4651
|
+
if (U.sep == "/")
|
|
4635
4652
|
return [
|
|
4636
4653
|
{
|
|
4637
4654
|
name: "local",
|
|
@@ -4640,9 +4657,9 @@ async function Io() {
|
|
|
4640
4657
|
}
|
|
4641
4658
|
];
|
|
4642
4659
|
{
|
|
4643
|
-
const t =
|
|
4660
|
+
const t = U.parse(s).root.replaceAll(":\\", "");
|
|
4644
4661
|
try {
|
|
4645
|
-
return (await
|
|
4662
|
+
return (await At.promisify(Mt)("wmic logicaldisk get name")).stdout.split(`\r
|
|
4646
4663
|
`).filter((o) => o.includes(":")).map((o) => o.trim().replaceAll(":", "")).map((o) => {
|
|
4647
4664
|
const c = o == t;
|
|
4648
4665
|
return {
|
|
@@ -4694,13 +4711,13 @@ class Tt {
|
|
|
4694
4711
|
* @private
|
|
4695
4712
|
*/
|
|
4696
4713
|
async tryResolveLocalFileHandle(e) {
|
|
4697
|
-
if (
|
|
4698
|
-
const t =
|
|
4714
|
+
if (Ct(e)) {
|
|
4715
|
+
const t = Lo(e), r = this.localProjectionsMap.get(t.storageId);
|
|
4699
4716
|
if (!r)
|
|
4700
4717
|
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4701
|
-
return
|
|
4718
|
+
return T.join(r.localPath, t.path);
|
|
4702
4719
|
} else {
|
|
4703
|
-
const t =
|
|
4720
|
+
const t = To(e);
|
|
4704
4721
|
this.signer.verify(
|
|
4705
4722
|
t.localPath,
|
|
4706
4723
|
t.pathSignature,
|
|
@@ -4713,17 +4730,17 @@ class Tt {
|
|
|
4713
4730
|
}
|
|
4714
4731
|
}
|
|
4715
4732
|
async getLocalFileHandle(e) {
|
|
4716
|
-
|
|
4733
|
+
O(e);
|
|
4717
4734
|
for (const r of this.localProjectionsMap.values())
|
|
4718
4735
|
if (e.startsWith(r.localPath)) {
|
|
4719
|
-
const n = r.localPath === "" ? e :
|
|
4736
|
+
const n = r.localPath === "" ? e : T.relative(r.localPath, e);
|
|
4720
4737
|
return we(
|
|
4721
4738
|
r.storageId,
|
|
4722
4739
|
n
|
|
4723
4740
|
);
|
|
4724
4741
|
}
|
|
4725
4742
|
const t = await w.stat(e, { bigint: !0 });
|
|
4726
|
-
return
|
|
4743
|
+
return ko(
|
|
4727
4744
|
e,
|
|
4728
4745
|
this.signer,
|
|
4729
4746
|
t.size,
|
|
@@ -4734,12 +4751,12 @@ class Tt {
|
|
|
4734
4751
|
async getStorageList() {
|
|
4735
4752
|
const e = [...this.virtualStoragesMap.values()].map((n) => ({
|
|
4736
4753
|
name: n.name,
|
|
4737
|
-
handle:
|
|
4754
|
+
handle: Po(n.name, n.root),
|
|
4738
4755
|
initialFullPath: n.initialPath
|
|
4739
4756
|
})), r = Object.entries(this.storageIdToResourceId).map(
|
|
4740
4757
|
([n, o]) => ({
|
|
4741
4758
|
name: n,
|
|
4742
|
-
handle:
|
|
4759
|
+
handle: $o(n, o),
|
|
4743
4760
|
initialFullPath: "",
|
|
4744
4761
|
// we don't have any additional information from where to start browsing remote storages
|
|
4745
4762
|
isInitialPathHome: !1
|
|
@@ -4758,11 +4775,11 @@ class Tt {
|
|
|
4758
4775
|
handle: we(r.name, i.fullName)
|
|
4759
4776
|
}))
|
|
4760
4777
|
};
|
|
4761
|
-
|
|
4762
|
-
const n =
|
|
4778
|
+
T.sep === "/" && t === "" && (t = "/"), r.rootPath === "" && O(t);
|
|
4779
|
+
const n = T.isAbsolute(t) ? t : T.join(r.rootPath, t), o = [];
|
|
4763
4780
|
for await (const c of await w.opendir(n)) {
|
|
4764
4781
|
if (!c.isFile() && !c.isDirectory()) continue;
|
|
4765
|
-
const i =
|
|
4782
|
+
const i = T.join(n, c.name);
|
|
4766
4783
|
o.push({
|
|
4767
4784
|
type: c.isFile() ? "file" : "dir",
|
|
4768
4785
|
name: c.name,
|
|
@@ -4792,10 +4809,10 @@ class Tt {
|
|
|
4792
4809
|
);
|
|
4793
4810
|
}
|
|
4794
4811
|
static async init(e, t, r, n, o, c) {
|
|
4795
|
-
const i =
|
|
4796
|
-
c || (c = await
|
|
4797
|
-
for (const d of c)
|
|
4798
|
-
for (const d of n) d.localPath !== "" &&
|
|
4812
|
+
const i = yn(t, e);
|
|
4813
|
+
c || (c = await Do());
|
|
4814
|
+
for (const d of c) O(d.root);
|
|
4815
|
+
for (const d of n) d.localPath !== "" && O(d.localPath);
|
|
4799
4816
|
const l = new Map(c.map((d) => [d.name, d])), a = new Map(n.map((d) => [d.storageId, d]));
|
|
4800
4817
|
if ((/* @__PURE__ */ new Set([...l.keys(), ...a.keys()])).size !== l.size + a.size)
|
|
4801
4818
|
throw new Error(
|
|
@@ -4804,7 +4821,7 @@ class Tt {
|
|
|
4804
4821
|
return new Tt(
|
|
4805
4822
|
e,
|
|
4806
4823
|
i,
|
|
4807
|
-
await
|
|
4824
|
+
await vo(t),
|
|
4808
4825
|
r,
|
|
4809
4826
|
l,
|
|
4810
4827
|
a,
|
|
@@ -4812,64 +4829,64 @@ class Tt {
|
|
|
4812
4829
|
);
|
|
4813
4830
|
}
|
|
4814
4831
|
}
|
|
4815
|
-
async function
|
|
4832
|
+
async function vo(s) {
|
|
4816
4833
|
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4817
4834
|
const t = await e.getResourceByName("LSProvider"), r = await e.getResourceData(t, !0);
|
|
4818
|
-
return
|
|
4835
|
+
return Bo(r);
|
|
4819
4836
|
});
|
|
4820
4837
|
}
|
|
4821
|
-
function
|
|
4838
|
+
function Bo(s) {
|
|
4822
4839
|
return Object.fromEntries(
|
|
4823
|
-
s.fields.filter((e) => e.type == "Dynamic" &&
|
|
4840
|
+
s.fields.filter((e) => e.type == "Dynamic" && Rt(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4824
4841
|
);
|
|
4825
4842
|
}
|
|
4826
4843
|
export {
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4844
|
+
Ar as ClientDownload,
|
|
4845
|
+
mn as ClientLogs,
|
|
4846
|
+
rn as ClientLs,
|
|
4847
|
+
vr as ClientProgress,
|
|
4848
|
+
ur as ClientUpload,
|
|
4849
|
+
Do as DefaultVirtualLocalStorages,
|
|
4850
|
+
ls as DownloadBlobToURLDriver,
|
|
4834
4851
|
pt as DownloadDriver,
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4852
|
+
us as DownloadUrlDriver,
|
|
4853
|
+
Jn as DownloadableBlobSnapshot,
|
|
4854
|
+
is as ImportFileHandleData,
|
|
4838
4855
|
st as ImportFileHandleIndexData,
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4856
|
+
re as ImportFileHandleUploadData,
|
|
4857
|
+
Pn as IndexResourceSnapshot,
|
|
4858
|
+
ds as LogsDriver,
|
|
4859
|
+
hs as LogsStreamDriver,
|
|
4843
4860
|
Tt as LsDriver,
|
|
4844
4861
|
Xe as MTimeError,
|
|
4845
4862
|
et as NetworkError,
|
|
4846
4863
|
tt as NoFileForUploading,
|
|
4847
|
-
|
|
4864
|
+
Ln as OnDemandBlobResourceSnapshot,
|
|
4848
4865
|
Ye as UnexpectedEOF,
|
|
4849
4866
|
Se as UnknownStorageError,
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4867
|
+
Sn as Updater,
|
|
4868
|
+
cs as UploadDriver,
|
|
4869
|
+
Un as UploadResourceSnapshot,
|
|
4870
|
+
no as UploadTask,
|
|
4854
4871
|
$e as WrongLocalFileUrl,
|
|
4855
4872
|
Ie as WrongResourceTypeError,
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4873
|
+
rs as createDownloadClient,
|
|
4874
|
+
ns as createLogsClient,
|
|
4875
|
+
yn as createLsFilesClient,
|
|
4876
|
+
ss as createUploadBlobClient,
|
|
4877
|
+
os as createUploadProgressClient,
|
|
4878
|
+
Hr as getFullPath,
|
|
4862
4879
|
ot as getSize,
|
|
4863
|
-
|
|
4880
|
+
io as isMyUpload,
|
|
4864
4881
|
Oe as isResourceWasDeletedError,
|
|
4865
|
-
|
|
4882
|
+
co as isSignMatch,
|
|
4866
4883
|
Le as isUpload,
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4884
|
+
wo as makeBlobImportSnapshot,
|
|
4885
|
+
Zn as makeDownloadableBlobSnapshot,
|
|
4886
|
+
Vr as newLocalStorageIdsToRoot,
|
|
4870
4887
|
mt as nonRecoverableError,
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4888
|
+
Mr as parseLocalUrl,
|
|
4889
|
+
oo as uploadBlob,
|
|
4890
|
+
O as validateAbsolute
|
|
4874
4891
|
};
|
|
4875
4892
|
//# sourceMappingURL=index.mjs.map
|