@milaboratories/pl-drivers 1.5.53 → 1.5.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drivers/{download_blob.d.ts → download_blob/download_blob.d.ts} +7 -8
- package/dist/drivers/download_blob/download_blob.d.ts.map +1 -0
- package/dist/drivers/{download_blob_task.d.ts → download_blob/download_blob_task.d.ts} +1 -1
- package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -0
- package/dist/drivers/helpers/files_cache.d.ts.map +1 -1
- package/dist/drivers/logs.d.ts +1 -1
- package/dist/drivers/logs.d.ts.map +1 -1
- package/dist/drivers/upload_task.d.ts +2 -0
- package/dist/drivers/upload_task.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +714 -709
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -11
- package/src/clients/download.test.ts +1 -1
- package/src/clients/upload.test.ts +2 -1
- package/src/drivers/{download_blob.test.ts → download_blob/download_blob.test.ts} +3 -3
- package/src/drivers/{download_blob.ts → download_blob/download_blob.ts} +59 -42
- package/src/drivers/{download_blob_task.ts → download_blob/download_blob_task.ts} +3 -3
- package/src/drivers/download_blob_url/driver.ts +1 -1
- package/src/drivers/download_blob_url/url.test.ts +1 -1
- package/src/drivers/download_url.test.ts +1 -1
- package/src/drivers/helpers/files_cache.test.ts +1 -1
- package/src/drivers/helpers/files_cache.ts +10 -3
- package/src/drivers/logs.test.ts +2 -2
- package/src/drivers/logs.ts +1 -1
- package/src/drivers/ls.test.ts +1 -1
- package/src/drivers/upload.test.ts +1 -1
- package/src/drivers/upload_task.ts +2 -2
- package/src/index.ts +1 -1
- package/dist/drivers/download_blob.d.ts.map +0 -1
- package/dist/drivers/download_blob_task.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (s, e, t) =>
|
|
4
|
-
import { addRTypeToMetadata as
|
|
1
|
+
var at = Object.defineProperty;
|
|
2
|
+
var lt = (s, e, t) => e in s ? at(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var d = (s, e, t) => lt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { addRTypeToMetadata as U, bigintToResourceId as pe, stringifyWithResourceId as b, resourceIdToString as ct, isNotNullResourceId as dt } from "@milaboratories/pl-client";
|
|
5
5
|
import * as m from "node:fs/promises";
|
|
6
|
-
import { request as
|
|
7
|
-
import { ServiceType as
|
|
8
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as
|
|
9
|
-
import { notEmpty as
|
|
10
|
-
import * as
|
|
11
|
-
import
|
|
12
|
-
import * as
|
|
13
|
-
import
|
|
14
|
-
import { Readable as
|
|
15
|
-
import { text as
|
|
16
|
-
import { ChangeSource as
|
|
17
|
-
import { rsSchema as
|
|
18
|
-
import
|
|
19
|
-
import { randomUUID as
|
|
20
|
-
import * as
|
|
21
|
-
import
|
|
22
|
-
import * as
|
|
23
|
-
import { z as
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
import
|
|
27
|
-
import { scheduler as
|
|
28
|
-
import
|
|
29
|
-
import { isImportFileHandleIndex as
|
|
30
|
-
import
|
|
31
|
-
import { exec as
|
|
32
|
-
class
|
|
6
|
+
import { request as Be } from "undici";
|
|
7
|
+
import { ServiceType as E, stackIntercept as k } from "@protobuf-ts/runtime-rpc";
|
|
8
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as R, typeofJsonValue as Ce, assertNever as ht } from "@protobuf-ts/runtime";
|
|
9
|
+
import { notEmpty as j, CallersCounter as N, ensureDirExists as ge, fileExists as fe, createPathAtomically as me, mapGet as De, mapEntries as ut, TaskProcessor as G, asyncPool as we, assertNever as pt } from "@milaboratories/ts-helpers";
|
|
10
|
+
import * as ye from "node:fs";
|
|
11
|
+
import le from "node:fs";
|
|
12
|
+
import * as T from "node:path";
|
|
13
|
+
import P from "node:path";
|
|
14
|
+
import { Readable as be, Writable as I, Transform as _e } from "node:stream";
|
|
15
|
+
import { text as gt, buffer as Ee } from "node:stream/consumers";
|
|
16
|
+
import { ChangeSource as $, Computable as y, PollingComputableHooks as Oe } from "@milaboratories/computable";
|
|
17
|
+
import { rsSchema as V, treeEntryToResourceInfo as S, isPlTreeEntry as O, makeResourceSnapshot as A, isPlTreeEntryAccessor as Fe } from "@milaboratories/pl-tree";
|
|
18
|
+
import ft from "denque";
|
|
19
|
+
import { randomUUID as D, createHash as mt } from "node:crypto";
|
|
20
|
+
import * as Re from "node:os";
|
|
21
|
+
import wt from "node:os";
|
|
22
|
+
import * as yt from "node:readline/promises";
|
|
23
|
+
import { z as L } from "zod";
|
|
24
|
+
import * as We from "node:zlib";
|
|
25
|
+
import * as ce from "tar-fs";
|
|
26
|
+
import bt from "decompress";
|
|
27
|
+
import { scheduler as ze } from "node:timers/promises";
|
|
28
|
+
import Tt from "node:assert";
|
|
29
|
+
import { isImportFileHandleIndex as kt } from "@milaboratories/pl-model-common";
|
|
30
|
+
import Lt from "node:util";
|
|
31
|
+
import { exec as Pt } from "node:child_process";
|
|
32
|
+
class Ut extends g {
|
|
33
33
|
constructor() {
|
|
34
34
|
super("MiLaboratories.Controller.Shared.uploadapi", []);
|
|
35
35
|
}
|
|
@@ -49,8 +49,8 @@ class Pt extends g {
|
|
|
49
49
|
), t;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
new
|
|
53
|
-
class
|
|
52
|
+
new Ut();
|
|
53
|
+
class Dt extends g {
|
|
54
54
|
constructor() {
|
|
55
55
|
super("MiLaboratories.Controller.Shared.uploadapi.Init", []);
|
|
56
56
|
}
|
|
@@ -70,8 +70,8 @@ class Ut extends g {
|
|
|
70
70
|
), t;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
new
|
|
74
|
-
class
|
|
73
|
+
new Dt();
|
|
74
|
+
class Rt extends g {
|
|
75
75
|
constructor() {
|
|
76
76
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
77
77
|
{
|
|
@@ -125,8 +125,8 @@ class Dt extends g {
|
|
|
125
125
|
), t;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
class
|
|
128
|
+
const St = new Rt();
|
|
129
|
+
class It extends g {
|
|
130
130
|
constructor() {
|
|
131
131
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
132
132
|
{
|
|
@@ -164,7 +164,7 @@ class St extends g {
|
|
|
164
164
|
case /* repeated uint64 uploaded_parts */
|
|
165
165
|
2:
|
|
166
166
|
if (c === h.LengthDelimited)
|
|
167
|
-
for (let
|
|
167
|
+
for (let Z = e.int32() + e.pos; e.pos < Z; )
|
|
168
168
|
r.uploadedParts.push(e.uint64().toBigInt());
|
|
169
169
|
else r.uploadedParts.push(e.uint64().toBigInt());
|
|
170
170
|
break;
|
|
@@ -201,8 +201,8 @@ class St extends g {
|
|
|
201
201
|
), t;
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
const
|
|
205
|
-
class
|
|
204
|
+
const vt = new It();
|
|
205
|
+
class Nt extends g {
|
|
206
206
|
constructor() {
|
|
207
207
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
208
208
|
}
|
|
@@ -222,8 +222,8 @@ class vt extends g {
|
|
|
222
222
|
), t;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
new
|
|
226
|
-
class
|
|
225
|
+
new Nt();
|
|
226
|
+
class $t extends g {
|
|
227
227
|
constructor() {
|
|
228
228
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
229
229
|
{
|
|
@@ -293,8 +293,8 @@ class Nt extends g {
|
|
|
293
293
|
), t;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
const
|
|
297
|
-
class
|
|
296
|
+
const Bt = new $t();
|
|
297
|
+
class Ct extends g {
|
|
298
298
|
constructor() {
|
|
299
299
|
super(
|
|
300
300
|
"MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Response",
|
|
@@ -321,8 +321,8 @@ class Bt extends g {
|
|
|
321
321
|
), t;
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
const
|
|
325
|
-
class
|
|
324
|
+
const _t = new Ct();
|
|
325
|
+
class Et extends g {
|
|
326
326
|
constructor() {
|
|
327
327
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL", []);
|
|
328
328
|
}
|
|
@@ -342,8 +342,8 @@ class _t extends g {
|
|
|
342
342
|
), t;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
new
|
|
346
|
-
class
|
|
345
|
+
new Et();
|
|
346
|
+
class Ot extends g {
|
|
347
347
|
constructor() {
|
|
348
348
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Request", [
|
|
349
349
|
{
|
|
@@ -425,8 +425,8 @@ class Et extends g {
|
|
|
425
425
|
), t;
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
const
|
|
429
|
-
class
|
|
428
|
+
const Ft = new Ot();
|
|
429
|
+
class Wt extends g {
|
|
430
430
|
constructor() {
|
|
431
431
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader", [
|
|
432
432
|
{
|
|
@@ -496,8 +496,8 @@ class Ft extends g {
|
|
|
496
496
|
), t;
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
|
-
const
|
|
500
|
-
class
|
|
499
|
+
const Q = new Wt();
|
|
500
|
+
class zt extends g {
|
|
501
501
|
constructor() {
|
|
502
502
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
503
503
|
{
|
|
@@ -519,7 +519,7 @@ class Wt extends g {
|
|
|
519
519
|
name: "headers",
|
|
520
520
|
kind: "message",
|
|
521
521
|
repeat: 1,
|
|
522
|
-
T: () =>
|
|
522
|
+
T: () => Q
|
|
523
523
|
},
|
|
524
524
|
{
|
|
525
525
|
no: 4,
|
|
@@ -563,7 +563,7 @@ class Wt extends g {
|
|
|
563
563
|
case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
|
|
564
564
|
3:
|
|
565
565
|
r.headers.push(
|
|
566
|
-
|
|
566
|
+
Q.internalBinaryRead(
|
|
567
567
|
e,
|
|
568
568
|
e.uint32(),
|
|
569
569
|
o
|
|
@@ -599,7 +599,7 @@ class Wt extends g {
|
|
|
599
599
|
internalBinaryWrite(e, t, o) {
|
|
600
600
|
e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
|
|
601
601
|
for (let r = 0; r < e.headers.length; r++)
|
|
602
|
-
|
|
602
|
+
Q.internalBinaryWrite(
|
|
603
603
|
e.headers[r],
|
|
604
604
|
t.tag(3, h.LengthDelimited).fork(),
|
|
605
605
|
o
|
|
@@ -613,8 +613,8 @@ class Wt extends g {
|
|
|
613
613
|
), t;
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
const
|
|
617
|
-
class
|
|
616
|
+
const xt = new zt();
|
|
617
|
+
class At extends g {
|
|
618
618
|
constructor() {
|
|
619
619
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize", []);
|
|
620
620
|
}
|
|
@@ -634,8 +634,8 @@ class xt extends g {
|
|
|
634
634
|
), t;
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
new
|
|
638
|
-
class
|
|
637
|
+
new At();
|
|
638
|
+
class Mt extends g {
|
|
639
639
|
constructor() {
|
|
640
640
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Request", [
|
|
641
641
|
{
|
|
@@ -689,8 +689,8 @@ class At extends g {
|
|
|
689
689
|
), t;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
const
|
|
693
|
-
class
|
|
692
|
+
const Ht = new Mt();
|
|
693
|
+
class jt extends g {
|
|
694
694
|
constructor() {
|
|
695
695
|
super("MiLaboratories.Controller.Shared.uploadapi.Finalize.Response", []);
|
|
696
696
|
}
|
|
@@ -710,40 +710,40 @@ class Ht extends g {
|
|
|
710
710
|
), t;
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
-
const
|
|
713
|
+
const Gt = new jt(), X = new E(
|
|
714
714
|
"MiLaboratories.Controller.Shared.Upload",
|
|
715
715
|
[
|
|
716
716
|
{
|
|
717
717
|
name: "Init",
|
|
718
718
|
options: {},
|
|
719
|
-
I:
|
|
720
|
-
O:
|
|
719
|
+
I: St,
|
|
720
|
+
O: vt
|
|
721
721
|
},
|
|
722
722
|
{
|
|
723
723
|
name: "GetPartURL",
|
|
724
724
|
options: {},
|
|
725
|
-
I:
|
|
726
|
-
O:
|
|
725
|
+
I: Ft,
|
|
726
|
+
O: xt
|
|
727
727
|
},
|
|
728
728
|
{
|
|
729
729
|
name: "UpdateProgress",
|
|
730
730
|
options: {},
|
|
731
|
-
I:
|
|
732
|
-
O:
|
|
731
|
+
I: Bt,
|
|
732
|
+
O: _t
|
|
733
733
|
},
|
|
734
734
|
{
|
|
735
735
|
name: "Finalize",
|
|
736
736
|
options: {},
|
|
737
|
-
I:
|
|
738
|
-
O:
|
|
737
|
+
I: Ht,
|
|
738
|
+
O: Gt
|
|
739
739
|
}
|
|
740
740
|
]
|
|
741
741
|
);
|
|
742
|
-
class
|
|
742
|
+
class Vt {
|
|
743
743
|
constructor(e) {
|
|
744
|
-
d(this, "typeName",
|
|
745
|
-
d(this, "methods",
|
|
746
|
-
d(this, "options",
|
|
744
|
+
d(this, "typeName", X.typeName);
|
|
745
|
+
d(this, "methods", X.methods);
|
|
746
|
+
d(this, "options", X.options);
|
|
747
747
|
this._transport = e;
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
@@ -755,7 +755,7 @@ class Gt {
|
|
|
755
755
|
*/
|
|
756
756
|
init(e, t) {
|
|
757
757
|
const o = this.methods[0], n = this._transport.mergeOptions(t);
|
|
758
|
-
return
|
|
758
|
+
return k(
|
|
759
759
|
"unary",
|
|
760
760
|
this._transport,
|
|
761
761
|
o,
|
|
@@ -773,7 +773,7 @@ class Gt {
|
|
|
773
773
|
*/
|
|
774
774
|
getPartURL(e, t) {
|
|
775
775
|
const o = this.methods[1], n = this._transport.mergeOptions(t);
|
|
776
|
-
return
|
|
776
|
+
return k("unary", this._transport, o, n, e);
|
|
777
777
|
}
|
|
778
778
|
/**
|
|
779
779
|
*
|
|
@@ -784,7 +784,7 @@ class Gt {
|
|
|
784
784
|
*/
|
|
785
785
|
updateProgress(e, t) {
|
|
786
786
|
const o = this.methods[2], n = this._transport.mergeOptions(t);
|
|
787
|
-
return
|
|
787
|
+
return k("unary", this._transport, o, n, e);
|
|
788
788
|
}
|
|
789
789
|
/**
|
|
790
790
|
*
|
|
@@ -797,25 +797,25 @@ class Gt {
|
|
|
797
797
|
*/
|
|
798
798
|
finalize(e, t) {
|
|
799
799
|
const o = this.methods[3], n = this._transport.mergeOptions(t);
|
|
800
|
-
return
|
|
800
|
+
return k("unary", this._transport, o, n, e);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function xe(s, e, t) {
|
|
804
804
|
const o = Object.fromEntries(s.map(({ name: n, value: r }) => [n, r]));
|
|
805
805
|
return e !== void 0 && t !== void 0 && (o.Range = `bytes=${e}-${t}`), o;
|
|
806
806
|
}
|
|
807
|
-
class xe extends Error {
|
|
808
|
-
}
|
|
809
807
|
class Ae extends Error {
|
|
810
808
|
}
|
|
811
809
|
class Me extends Error {
|
|
812
810
|
}
|
|
813
811
|
class He extends Error {
|
|
814
812
|
}
|
|
815
|
-
class
|
|
813
|
+
class je extends Error {
|
|
814
|
+
}
|
|
815
|
+
class qt {
|
|
816
816
|
constructor(e, t, o, n) {
|
|
817
817
|
d(this, "grpcClient");
|
|
818
|
-
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new
|
|
818
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Vt(this.grpcTransport);
|
|
819
819
|
}
|
|
820
820
|
close() {
|
|
821
821
|
}
|
|
@@ -833,14 +833,14 @@ class Vt {
|
|
|
833
833
|
0n,
|
|
834
834
|
// we update progress as a separate call later.
|
|
835
835
|
a
|
|
836
|
-
), c = await
|
|
837
|
-
await
|
|
836
|
+
), c = await Jt(o, i.chunkStart, i.chunkEnd);
|
|
837
|
+
await Qt(o, n);
|
|
838
838
|
try {
|
|
839
839
|
const {
|
|
840
840
|
body: l,
|
|
841
841
|
statusCode: p,
|
|
842
|
-
headers:
|
|
843
|
-
} = await
|
|
842
|
+
headers: Z
|
|
843
|
+
} = await Be(i.uploadUrl, {
|
|
844
844
|
dispatcher: this.httpClient,
|
|
845
845
|
body: c,
|
|
846
846
|
// We got headers only after we send
|
|
@@ -849,12 +849,12 @@ class Vt {
|
|
|
849
849
|
// that's why we got big timeout here.
|
|
850
850
|
headersTimeout: 6e4,
|
|
851
851
|
bodyTimeout: 6e4,
|
|
852
|
-
headers:
|
|
852
|
+
headers: xe(i.headers),
|
|
853
853
|
method: i.method.toUpperCase()
|
|
854
|
-
}),
|
|
855
|
-
|
|
854
|
+
}), it = await l.text();
|
|
855
|
+
Xt(p, it, Z, i);
|
|
856
856
|
} catch (l) {
|
|
857
|
-
throw l instanceof
|
|
857
|
+
throw l instanceof He ? l : new Error(`partUpload: error ${JSON.stringify(l)} happened while trying to do part upload to the url ${i.uploadUrl}, headers: ${JSON.stringify(i.headers)}`);
|
|
858
858
|
}
|
|
859
859
|
await this.grpcUpdateProgress({ id: e, type: t }, BigInt(i.chunkEnd - i.chunkStart), a);
|
|
860
860
|
}
|
|
@@ -870,12 +870,12 @@ class Vt {
|
|
|
870
870
|
return o;
|
|
871
871
|
}
|
|
872
872
|
async grpcInit(e, t, o) {
|
|
873
|
-
return await this.grpcClient.init({ resourceId: e },
|
|
873
|
+
return await this.grpcClient.init({ resourceId: e }, U(t, o)).response;
|
|
874
874
|
}
|
|
875
875
|
async grpcGetPartUrl({ id: e, type: t }, o, n, r) {
|
|
876
876
|
return await this.grpcClient.getPartURL(
|
|
877
877
|
{ resourceId: e, partNumber: o, uploadedPartSize: n },
|
|
878
|
-
|
|
878
|
+
U(t, r)
|
|
879
879
|
).response;
|
|
880
880
|
}
|
|
881
881
|
async grpcUpdateProgress({ id: e, type: t }, o, n) {
|
|
@@ -884,26 +884,26 @@ class Vt {
|
|
|
884
884
|
resourceId: e,
|
|
885
885
|
bytesProcessed: o
|
|
886
886
|
},
|
|
887
|
-
|
|
887
|
+
U(t, n)
|
|
888
888
|
).response;
|
|
889
889
|
}
|
|
890
890
|
async grpcFinalize({ id: e, type: t }, o) {
|
|
891
|
-
return await this.grpcClient.finalize({ resourceId: e },
|
|
891
|
+
return await this.grpcClient.finalize({ resourceId: e }, U(t, o)).response;
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
async function
|
|
894
|
+
async function Jt(s, e, t) {
|
|
895
895
|
let o;
|
|
896
896
|
try {
|
|
897
897
|
o = await m.open(s);
|
|
898
|
-
const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await
|
|
898
|
+
const n = Number(t - e), r = Number(e), a = Buffer.alloc(n), i = await Zt(o, a, n, r);
|
|
899
899
|
return a.subarray(0, i);
|
|
900
900
|
} catch (n) {
|
|
901
|
-
throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new
|
|
901
|
+
throw n && typeof n == "object" && "code" in n && n.code == "ENOENT" ? new je(`there is no file ${s} for uploading`) : n;
|
|
902
902
|
} finally {
|
|
903
903
|
await (o == null ? void 0 : o.close());
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
async function
|
|
906
|
+
async function Zt(s, e, t, o) {
|
|
907
907
|
let n = 0;
|
|
908
908
|
for (; n < t; ) {
|
|
909
909
|
const { bytesRead: r } = await s.read(
|
|
@@ -913,23 +913,23 @@ async function Jt(s, e, t, o) {
|
|
|
913
913
|
o + n
|
|
914
914
|
);
|
|
915
915
|
if (r === 0)
|
|
916
|
-
throw new
|
|
916
|
+
throw new Me("file ended earlier than expected.");
|
|
917
917
|
n += r;
|
|
918
918
|
}
|
|
919
919
|
return n;
|
|
920
920
|
}
|
|
921
|
-
async function
|
|
921
|
+
async function Qt(s, e) {
|
|
922
922
|
const t = BigInt(Math.floor((await m.stat(s)).mtimeMs / 1e3));
|
|
923
923
|
if (t > e)
|
|
924
|
-
throw new
|
|
924
|
+
throw new Ae(`file was modified, expected mtime: ${e}, got: ${t}.`);
|
|
925
925
|
}
|
|
926
|
-
function
|
|
926
|
+
function Xt(s, e, t, o) {
|
|
927
927
|
if (s != 200)
|
|
928
|
-
throw new
|
|
928
|
+
throw new He(
|
|
929
929
|
`response is not ok, status code: ${s}, body: ${e}, headers: ${JSON.stringify(t)}, url: ${o.uploadUrl}`
|
|
930
930
|
);
|
|
931
931
|
}
|
|
932
|
-
class
|
|
932
|
+
class Kt extends g {
|
|
933
933
|
constructor() {
|
|
934
934
|
super("google.protobuf.Duration", [
|
|
935
935
|
{
|
|
@@ -953,7 +953,7 @@ class Xt extends g {
|
|
|
953
953
|
* Encode `Duration` to JSON string like "3.000001s".
|
|
954
954
|
*/
|
|
955
955
|
internalJsonWrite(e, t) {
|
|
956
|
-
const o =
|
|
956
|
+
const o = R.from(e.seconds).toNumber();
|
|
957
957
|
if (o > 315576e6 || o < -315576e6)
|
|
958
958
|
throw new Error("Duration value out of range.");
|
|
959
959
|
let n = e.seconds.toString();
|
|
@@ -969,7 +969,7 @@ class Xt extends g {
|
|
|
969
969
|
internalJsonRead(e, t, o) {
|
|
970
970
|
if (typeof e != "string")
|
|
971
971
|
throw new Error(
|
|
972
|
-
"Unable to parse Duration from JSON " +
|
|
972
|
+
"Unable to parse Duration from JSON " + Ce(e) + ". Expected string."
|
|
973
973
|
);
|
|
974
974
|
const n = e.match(/^(-?)([0-9]+)(?:\.([0-9]+))?s/);
|
|
975
975
|
if (n === null)
|
|
@@ -977,7 +977,7 @@ class Xt extends g {
|
|
|
977
977
|
"Unable to parse Duration from JSON string. Invalid format."
|
|
978
978
|
);
|
|
979
979
|
o || (o = this.create());
|
|
980
|
-
const [, r, a, i] = n, c =
|
|
980
|
+
const [, r, a, i] = n, c = R.from(r + a);
|
|
981
981
|
if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
|
|
982
982
|
throw new Error(
|
|
983
983
|
"Unable to parse Duration from JSON string. Value out of range."
|
|
@@ -1033,8 +1033,8 @@ class Xt extends g {
|
|
|
1033
1033
|
), t;
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
|
-
const
|
|
1037
|
-
class
|
|
1036
|
+
const x = new Kt();
|
|
1037
|
+
class Yt extends g {
|
|
1038
1038
|
constructor() {
|
|
1039
1039
|
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
1040
1040
|
}
|
|
@@ -1054,8 +1054,8 @@ class Kt extends g {
|
|
|
1054
1054
|
), t;
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
-
new
|
|
1058
|
-
class
|
|
1057
|
+
new Yt();
|
|
1058
|
+
class eo extends g {
|
|
1059
1059
|
constructor() {
|
|
1060
1060
|
super("MiLaboratories.Controller.Shared.ProgressAPI.Report", [
|
|
1061
1061
|
{
|
|
@@ -1154,8 +1154,8 @@ class Yt extends g {
|
|
|
1154
1154
|
), t;
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
|
-
const
|
|
1158
|
-
class
|
|
1157
|
+
const v = new eo();
|
|
1158
|
+
class to extends g {
|
|
1159
1159
|
constructor() {
|
|
1160
1160
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
1161
1161
|
}
|
|
@@ -1175,8 +1175,8 @@ class eo extends g {
|
|
|
1175
1175
|
), t;
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
|
-
new
|
|
1179
|
-
class
|
|
1178
|
+
new to();
|
|
1179
|
+
class oo extends g {
|
|
1180
1180
|
constructor() {
|
|
1181
1181
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Request", [
|
|
1182
1182
|
{
|
|
@@ -1234,11 +1234,11 @@ class to extends g {
|
|
|
1234
1234
|
), t;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
class
|
|
1237
|
+
const no = new oo();
|
|
1238
|
+
class ro extends g {
|
|
1239
1239
|
constructor() {
|
|
1240
1240
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1241
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1241
|
+
{ no: 1, name: "report", kind: "message", T: () => v }
|
|
1242
1242
|
]);
|
|
1243
1243
|
}
|
|
1244
1244
|
create(e) {
|
|
@@ -1256,7 +1256,7 @@ class no extends g {
|
|
|
1256
1256
|
switch (i) {
|
|
1257
1257
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1258
1258
|
1:
|
|
1259
|
-
r.report =
|
|
1259
|
+
r.report = v.internalBinaryRead(
|
|
1260
1260
|
e,
|
|
1261
1261
|
e.uint32(),
|
|
1262
1262
|
o,
|
|
@@ -1282,7 +1282,7 @@ class no extends g {
|
|
|
1282
1282
|
return r;
|
|
1283
1283
|
}
|
|
1284
1284
|
internalBinaryWrite(e, t, o) {
|
|
1285
|
-
e.report &&
|
|
1285
|
+
e.report && v.internalBinaryWrite(
|
|
1286
1286
|
e.report,
|
|
1287
1287
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1288
1288
|
o
|
|
@@ -1295,8 +1295,8 @@ class no extends g {
|
|
|
1295
1295
|
), t;
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
|
-
const
|
|
1299
|
-
class
|
|
1298
|
+
const so = new ro();
|
|
1299
|
+
class io extends g {
|
|
1300
1300
|
constructor() {
|
|
1301
1301
|
super("MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus", []);
|
|
1302
1302
|
}
|
|
@@ -1316,8 +1316,8 @@ class so extends g {
|
|
|
1316
1316
|
), t;
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
|
-
new
|
|
1320
|
-
class
|
|
1319
|
+
new io();
|
|
1320
|
+
class ao extends g {
|
|
1321
1321
|
constructor() {
|
|
1322
1322
|
super(
|
|
1323
1323
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request",
|
|
@@ -1330,7 +1330,7 @@ class io extends g {
|
|
|
1330
1330
|
L: 0
|
|
1331
1331
|
/* LongType.BIGINT */
|
|
1332
1332
|
},
|
|
1333
|
-
{ no: 2, name: "update_interval", kind: "message", T: () =>
|
|
1333
|
+
{ no: 2, name: "update_interval", kind: "message", T: () => x }
|
|
1334
1334
|
]
|
|
1335
1335
|
);
|
|
1336
1336
|
}
|
|
@@ -1353,7 +1353,7 @@ class io extends g {
|
|
|
1353
1353
|
break;
|
|
1354
1354
|
case /* google.protobuf.Duration update_interval */
|
|
1355
1355
|
2:
|
|
1356
|
-
r.updateInterval =
|
|
1356
|
+
r.updateInterval = x.internalBinaryRead(
|
|
1357
1357
|
e,
|
|
1358
1358
|
e.uint32(),
|
|
1359
1359
|
o,
|
|
@@ -1379,7 +1379,7 @@ class io extends g {
|
|
|
1379
1379
|
return r;
|
|
1380
1380
|
}
|
|
1381
1381
|
internalBinaryWrite(e, t, o) {
|
|
1382
|
-
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval &&
|
|
1382
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && x.internalBinaryWrite(
|
|
1383
1383
|
e.updateInterval,
|
|
1384
1384
|
t.tag(2, h.LengthDelimited).fork(),
|
|
1385
1385
|
o
|
|
@@ -1392,12 +1392,12 @@ class io extends g {
|
|
|
1392
1392
|
), t;
|
|
1393
1393
|
}
|
|
1394
1394
|
}
|
|
1395
|
-
const
|
|
1396
|
-
class
|
|
1395
|
+
const lo = new ao();
|
|
1396
|
+
class co extends g {
|
|
1397
1397
|
constructor() {
|
|
1398
1398
|
super(
|
|
1399
1399
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
|
|
1400
|
-
[{ no: 1, name: "report", kind: "message", T: () =>
|
|
1400
|
+
[{ no: 1, name: "report", kind: "message", T: () => v }]
|
|
1401
1401
|
);
|
|
1402
1402
|
}
|
|
1403
1403
|
create(e) {
|
|
@@ -1415,7 +1415,7 @@ class lo extends g {
|
|
|
1415
1415
|
switch (i) {
|
|
1416
1416
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1417
1417
|
1:
|
|
1418
|
-
r.report =
|
|
1418
|
+
r.report = v.internalBinaryRead(
|
|
1419
1419
|
e,
|
|
1420
1420
|
e.uint32(),
|
|
1421
1421
|
o,
|
|
@@ -1441,7 +1441,7 @@ class lo extends g {
|
|
|
1441
1441
|
return r;
|
|
1442
1442
|
}
|
|
1443
1443
|
internalBinaryWrite(e, t, o) {
|
|
1444
|
-
e.report &&
|
|
1444
|
+
e.report && v.internalBinaryWrite(
|
|
1445
1445
|
e.report,
|
|
1446
1446
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1447
1447
|
o
|
|
@@ -1454,7 +1454,7 @@ class lo extends g {
|
|
|
1454
1454
|
), t;
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
-
const
|
|
1457
|
+
const ho = new co(), K = new E(
|
|
1458
1458
|
"MiLaboratories.Controller.Shared.Progress",
|
|
1459
1459
|
[
|
|
1460
1460
|
{
|
|
@@ -1462,23 +1462,23 @@ const co = new lo(), X = new _(
|
|
|
1462
1462
|
options: {
|
|
1463
1463
|
"google.api.http": { get: "/resources/{resource_id}/get-progress" }
|
|
1464
1464
|
},
|
|
1465
|
-
I:
|
|
1466
|
-
O:
|
|
1465
|
+
I: no,
|
|
1466
|
+
O: so
|
|
1467
1467
|
},
|
|
1468
1468
|
{
|
|
1469
1469
|
name: "RealtimeStatus",
|
|
1470
1470
|
serverStreaming: !0,
|
|
1471
1471
|
options: {},
|
|
1472
|
-
I:
|
|
1473
|
-
O:
|
|
1472
|
+
I: lo,
|
|
1473
|
+
O: ho
|
|
1474
1474
|
}
|
|
1475
1475
|
]
|
|
1476
1476
|
);
|
|
1477
|
-
class
|
|
1477
|
+
class uo {
|
|
1478
1478
|
constructor(e) {
|
|
1479
|
-
d(this, "typeName",
|
|
1480
|
-
d(this, "methods",
|
|
1481
|
-
d(this, "options",
|
|
1479
|
+
d(this, "typeName", K.typeName);
|
|
1480
|
+
d(this, "methods", K.methods);
|
|
1481
|
+
d(this, "options", K.options);
|
|
1482
1482
|
this._transport = e;
|
|
1483
1483
|
}
|
|
1484
1484
|
/**
|
|
@@ -1486,20 +1486,20 @@ class ho {
|
|
|
1486
1486
|
*/
|
|
1487
1487
|
getStatus(e, t) {
|
|
1488
1488
|
const o = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1489
|
-
return
|
|
1489
|
+
return k("unary", this._transport, o, n, e);
|
|
1490
1490
|
}
|
|
1491
1491
|
/**
|
|
1492
1492
|
* @generated from protobuf rpc: RealtimeStatus(MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Request) returns (stream MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response);
|
|
1493
1493
|
*/
|
|
1494
1494
|
realtimeStatus(e, t) {
|
|
1495
1495
|
const o = this.methods[1], n = this._transport.mergeOptions(t);
|
|
1496
|
-
return
|
|
1496
|
+
return k("serverStreaming", this._transport, o, n, e);
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
|
-
class
|
|
1499
|
+
class po {
|
|
1500
1500
|
constructor(e, t, o, n) {
|
|
1501
1501
|
d(this, "grpcClient");
|
|
1502
|
-
this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new
|
|
1502
|
+
this.grpcTransport = e, this.client = o, this.logger = n, this.grpcClient = new uo(this.grpcTransport);
|
|
1503
1503
|
}
|
|
1504
1504
|
close() {
|
|
1505
1505
|
}
|
|
@@ -1507,8 +1507,8 @@ class uo {
|
|
|
1507
1507
|
async getStatus({ id: e, type: t }, o) {
|
|
1508
1508
|
const n = await this.grpcClient.getStatus(
|
|
1509
1509
|
{ resourceId: e },
|
|
1510
|
-
|
|
1511
|
-
), r =
|
|
1510
|
+
U(t, o)
|
|
1511
|
+
), r = j(n.response.report);
|
|
1512
1512
|
return {
|
|
1513
1513
|
done: r.done,
|
|
1514
1514
|
progress: r.progress,
|
|
@@ -1519,8 +1519,8 @@ class uo {
|
|
|
1519
1519
|
// realtimeStatus returns a async generator that takes statuses from
|
|
1520
1520
|
// GRPC stream every updateIntervalMs milliseconds.
|
|
1521
1521
|
async *realtimeStatus({ id: e, type: t }, o = 100, n) {
|
|
1522
|
-
n =
|
|
1523
|
-
const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i =
|
|
1522
|
+
n = U(t, n);
|
|
1523
|
+
const r = Math.floor(o / 1e3), a = (o - r * 1e3) * 1e6, i = x.create({
|
|
1524
1524
|
seconds: BigInt(r),
|
|
1525
1525
|
nanos: a
|
|
1526
1526
|
});
|
|
@@ -1538,37 +1538,37 @@ class uo {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
|
-
class
|
|
1541
|
+
class q extends Error {
|
|
1542
1542
|
}
|
|
1543
|
-
class
|
|
1543
|
+
class Ge {
|
|
1544
1544
|
constructor(e) {
|
|
1545
1545
|
this.httpClient = e;
|
|
1546
1546
|
}
|
|
1547
1547
|
async download(e, t, o) {
|
|
1548
|
-
const { statusCode: n, body: r, headers: a } = await
|
|
1548
|
+
const { statusCode: n, body: r, headers: a } = await Be(e, {
|
|
1549
1549
|
dispatcher: this.httpClient,
|
|
1550
1550
|
headers: t,
|
|
1551
1551
|
signal: o
|
|
1552
|
-
}), i =
|
|
1553
|
-
return await
|
|
1552
|
+
}), i = be.toWeb(r);
|
|
1553
|
+
return await go(n, i, e), {
|
|
1554
1554
|
content: i,
|
|
1555
1555
|
size: Number(a["content-length"])
|
|
1556
1556
|
};
|
|
1557
1557
|
}
|
|
1558
1558
|
}
|
|
1559
|
-
async function
|
|
1559
|
+
async function go(s, e, t) {
|
|
1560
1560
|
if (s != 200 && s != 206) {
|
|
1561
|
-
const o = (await
|
|
1562
|
-
throw 400 <= s && s < 500 ? new
|
|
1561
|
+
const o = (await gt(e)).substring(0, 1e3);
|
|
1562
|
+
throw 400 <= s && s < 500 ? new q(
|
|
1563
1563
|
`Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${o}`
|
|
1564
1564
|
) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
|
-
function
|
|
1568
|
-
if (!
|
|
1567
|
+
function _(s) {
|
|
1568
|
+
if (!P.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1569
1569
|
return s;
|
|
1570
1570
|
}
|
|
1571
|
-
class
|
|
1571
|
+
class fo extends g {
|
|
1572
1572
|
constructor() {
|
|
1573
1573
|
super("MiLaboratories.Controller.Shared.DownloadAPI", []);
|
|
1574
1574
|
}
|
|
@@ -1588,8 +1588,8 @@ class go extends g {
|
|
|
1588
1588
|
), t;
|
|
1589
1589
|
}
|
|
1590
1590
|
}
|
|
1591
|
-
new
|
|
1592
|
-
class
|
|
1591
|
+
new fo();
|
|
1592
|
+
class mo extends g {
|
|
1593
1593
|
constructor() {
|
|
1594
1594
|
super("MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL", []);
|
|
1595
1595
|
}
|
|
@@ -1609,8 +1609,8 @@ class fo extends g {
|
|
|
1609
1609
|
), t;
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
|
-
new
|
|
1613
|
-
class
|
|
1612
|
+
new mo();
|
|
1613
|
+
class wo extends g {
|
|
1614
1614
|
constructor() {
|
|
1615
1615
|
super(
|
|
1616
1616
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Request",
|
|
@@ -1671,8 +1671,8 @@ class mo extends g {
|
|
|
1671
1671
|
), t;
|
|
1672
1672
|
}
|
|
1673
1673
|
}
|
|
1674
|
-
const
|
|
1675
|
-
class
|
|
1674
|
+
const yo = new wo();
|
|
1675
|
+
class bo extends g {
|
|
1676
1676
|
constructor() {
|
|
1677
1677
|
super(
|
|
1678
1678
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader",
|
|
@@ -1745,8 +1745,8 @@ class yo extends g {
|
|
|
1745
1745
|
), t;
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
|
-
const
|
|
1749
|
-
class
|
|
1748
|
+
const Y = new bo();
|
|
1749
|
+
class To extends g {
|
|
1750
1750
|
constructor() {
|
|
1751
1751
|
super(
|
|
1752
1752
|
"MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.Response",
|
|
@@ -1763,7 +1763,7 @@ class bo extends g {
|
|
|
1763
1763
|
name: "headers",
|
|
1764
1764
|
kind: "message",
|
|
1765
1765
|
repeat: 1,
|
|
1766
|
-
T: () =>
|
|
1766
|
+
T: () => Y
|
|
1767
1767
|
}
|
|
1768
1768
|
]
|
|
1769
1769
|
);
|
|
@@ -1788,7 +1788,7 @@ class bo extends g {
|
|
|
1788
1788
|
case /* repeated MiLaboratories.Controller.Shared.DownloadAPI.GetDownloadURL.HTTPHeader headers */
|
|
1789
1789
|
2:
|
|
1790
1790
|
r.headers.push(
|
|
1791
|
-
|
|
1791
|
+
Y.internalBinaryRead(
|
|
1792
1792
|
e,
|
|
1793
1793
|
e.uint32(),
|
|
1794
1794
|
o
|
|
@@ -1816,7 +1816,7 @@ class bo extends g {
|
|
|
1816
1816
|
internalBinaryWrite(e, t, o) {
|
|
1817
1817
|
e.downloadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.downloadUrl);
|
|
1818
1818
|
for (let r = 0; r < e.headers.length; r++)
|
|
1819
|
-
|
|
1819
|
+
Y.internalBinaryWrite(
|
|
1820
1820
|
e.headers[r],
|
|
1821
1821
|
t.tag(2, h.LengthDelimited).fork(),
|
|
1822
1822
|
o
|
|
@@ -1829,7 +1829,7 @@ class bo extends g {
|
|
|
1829
1829
|
), t;
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
1832
|
-
const
|
|
1832
|
+
const ko = new To(), ee = new E(
|
|
1833
1833
|
"MiLaboratories.Controller.Shared.Download",
|
|
1834
1834
|
[
|
|
1835
1835
|
{
|
|
@@ -1837,16 +1837,16 @@ const To = new bo(), Y = new _(
|
|
|
1837
1837
|
options: {
|
|
1838
1838
|
"google.api.http": { get: "/resources/{resource_id}/get-download-url" }
|
|
1839
1839
|
},
|
|
1840
|
-
I:
|
|
1841
|
-
O:
|
|
1840
|
+
I: yo,
|
|
1841
|
+
O: ko
|
|
1842
1842
|
}
|
|
1843
1843
|
]
|
|
1844
1844
|
);
|
|
1845
|
-
class
|
|
1845
|
+
class Lo {
|
|
1846
1846
|
constructor(e) {
|
|
1847
|
-
d(this, "typeName",
|
|
1848
|
-
d(this, "methods",
|
|
1849
|
-
d(this, "options",
|
|
1847
|
+
d(this, "typeName", ee.typeName);
|
|
1848
|
+
d(this, "methods", ee.methods);
|
|
1849
|
+
d(this, "options", ee.options);
|
|
1850
1850
|
this._transport = e;
|
|
1851
1851
|
}
|
|
1852
1852
|
/**
|
|
@@ -1854,29 +1854,29 @@ class ko {
|
|
|
1854
1854
|
*/
|
|
1855
1855
|
getDownloadURL(e, t) {
|
|
1856
1856
|
const o = this.methods[0], n = this._transport.mergeOptions(t);
|
|
1857
|
-
return
|
|
1857
|
+
return k("unary", this._transport, o, n, e);
|
|
1858
1858
|
}
|
|
1859
1859
|
}
|
|
1860
|
-
class
|
|
1860
|
+
class Po {
|
|
1861
1861
|
constructor(e, t, o, n) {
|
|
1862
1862
|
d(this, "grpcClient");
|
|
1863
1863
|
d(this, "remoteFileDownloader");
|
|
1864
1864
|
/** Helps to find a storage root directory by a storage id from URL scheme. */
|
|
1865
1865
|
d(this, "localStorageIdsToRoot");
|
|
1866
|
-
this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new
|
|
1866
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Lo(this.grpcTransport), this.remoteFileDownloader = new Ge(t), this.localStorageIdsToRoot = Io(n);
|
|
1867
1867
|
}
|
|
1868
1868
|
close() {
|
|
1869
1869
|
}
|
|
1870
1870
|
/** Gets a presign URL and downloads the file.
|
|
1871
1871
|
* An optional range with 2 numbers from what byte and to what byte to download can be provided. */
|
|
1872
1872
|
async downloadBlob(e, t, o, n, r) {
|
|
1873
|
-
const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c =
|
|
1874
|
-
return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`),
|
|
1873
|
+
const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, o), c = xe(i, n, r);
|
|
1874
|
+
return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), So(a) ? await this.readLocalFile(a, n, r) : await this.remoteFileDownloader.download(a, c, o);
|
|
1875
1875
|
}
|
|
1876
1876
|
async readLocalFile(e, t, o) {
|
|
1877
|
-
const { storageId: n, relativePath: r } =
|
|
1877
|
+
const { storageId: n, relativePath: r } = Uo(e), a = Do(n, this.localStorageIdsToRoot, r);
|
|
1878
1878
|
return {
|
|
1879
|
-
content:
|
|
1879
|
+
content: be.toWeb(ye.createReadStream(a, { start: t, end: o })),
|
|
1880
1880
|
size: (await m.stat(a)).size
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
@@ -1884,39 +1884,39 @@ class Lo {
|
|
|
1884
1884
|
const r = o ?? {};
|
|
1885
1885
|
return r.abort = n, await this.grpcClient.getDownloadURL(
|
|
1886
1886
|
{ resourceId: e },
|
|
1887
|
-
|
|
1887
|
+
U(t, r)
|
|
1888
1888
|
).response;
|
|
1889
1889
|
}
|
|
1890
1890
|
}
|
|
1891
|
-
function
|
|
1891
|
+
function Uo(s) {
|
|
1892
1892
|
const e = new URL(s);
|
|
1893
1893
|
if (e.pathname == "")
|
|
1894
|
-
throw new
|
|
1894
|
+
throw new Te(`url for local filepath ${s} does not match url scheme`);
|
|
1895
1895
|
return {
|
|
1896
1896
|
storageId: e.host,
|
|
1897
1897
|
relativePath: decodeURIComponent(e.pathname.slice(1))
|
|
1898
1898
|
};
|
|
1899
1899
|
}
|
|
1900
|
-
function
|
|
1900
|
+
function Do(s, e, t) {
|
|
1901
1901
|
const o = e.get(s);
|
|
1902
|
-
if (o === void 0) throw new
|
|
1903
|
-
return o === "" ? t :
|
|
1904
|
-
}
|
|
1905
|
-
const Do = "storage://";
|
|
1906
|
-
function Ro(s) {
|
|
1907
|
-
return s.startsWith(Do);
|
|
1902
|
+
if (o === void 0) throw new ke(`Unknown storage location: ${s}`);
|
|
1903
|
+
return o === "" ? t : T.join(o, t);
|
|
1908
1904
|
}
|
|
1909
|
-
|
|
1905
|
+
const Ro = "storage://";
|
|
1906
|
+
function So(s) {
|
|
1907
|
+
return s.startsWith(Ro);
|
|
1910
1908
|
}
|
|
1911
1909
|
class Te extends Error {
|
|
1912
1910
|
}
|
|
1913
|
-
|
|
1911
|
+
class ke extends Error {
|
|
1912
|
+
}
|
|
1913
|
+
function Io(s) {
|
|
1914
1914
|
const e = /* @__PURE__ */ new Map();
|
|
1915
1915
|
for (const t of s)
|
|
1916
|
-
t.localPath !== "" &&
|
|
1916
|
+
t.localPath !== "" && _(t.localPath), e.set(t.storageId, t.localPath);
|
|
1917
1917
|
return e;
|
|
1918
1918
|
}
|
|
1919
|
-
class
|
|
1919
|
+
class vo extends g {
|
|
1920
1920
|
constructor() {
|
|
1921
1921
|
super("google.protobuf.Timestamp", [
|
|
1922
1922
|
{
|
|
@@ -1941,14 +1941,14 @@ class Io extends g {
|
|
|
1941
1941
|
*/
|
|
1942
1942
|
now() {
|
|
1943
1943
|
const e = this.create(), t = Date.now();
|
|
1944
|
-
return e.seconds =
|
|
1944
|
+
return e.seconds = R.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
|
|
1945
1945
|
}
|
|
1946
1946
|
/**
|
|
1947
1947
|
* Converts a `Timestamp` to a JavaScript Date.
|
|
1948
1948
|
*/
|
|
1949
1949
|
toDate(e) {
|
|
1950
1950
|
return new Date(
|
|
1951
|
-
|
|
1951
|
+
R.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
|
|
1952
1952
|
);
|
|
1953
1953
|
}
|
|
1954
1954
|
/**
|
|
@@ -1956,14 +1956,14 @@ class Io extends g {
|
|
|
1956
1956
|
*/
|
|
1957
1957
|
fromDate(e) {
|
|
1958
1958
|
const t = this.create(), o = e.getTime();
|
|
1959
|
-
return t.seconds =
|
|
1959
|
+
return t.seconds = R.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
|
|
1960
1960
|
}
|
|
1961
1961
|
/**
|
|
1962
1962
|
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1963
1963
|
* in the RFC 3339 format.
|
|
1964
1964
|
*/
|
|
1965
1965
|
internalJsonWrite(e, t) {
|
|
1966
|
-
const o =
|
|
1966
|
+
const o = R.from(e.seconds).toNumber() * 1e3;
|
|
1967
1967
|
if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
|
|
1968
1968
|
throw new Error(
|
|
1969
1969
|
"Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
@@ -1986,7 +1986,7 @@ class Io extends g {
|
|
|
1986
1986
|
internalJsonRead(e, t, o) {
|
|
1987
1987
|
if (typeof e != "string")
|
|
1988
1988
|
throw new Error(
|
|
1989
|
-
"Unable to parse Timestamp from JSON " +
|
|
1989
|
+
"Unable to parse Timestamp from JSON " + Ce(e) + "."
|
|
1990
1990
|
);
|
|
1991
1991
|
const n = e.match(
|
|
1992
1992
|
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/
|
|
@@ -2002,7 +2002,7 @@ class Io extends g {
|
|
|
2002
2002
|
throw new globalThis.Error(
|
|
2003
2003
|
"Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
2004
2004
|
);
|
|
2005
|
-
return o || (o = this.create()), o.seconds =
|
|
2005
|
+
return o || (o = this.create()), o.seconds = R.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
|
|
2006
2006
|
}
|
|
2007
2007
|
create(e) {
|
|
2008
2008
|
const t = globalThis.Object.create(this.messagePrototype);
|
|
@@ -2049,8 +2049,8 @@ class Io extends g {
|
|
|
2049
2049
|
), t;
|
|
2050
2050
|
}
|
|
2051
2051
|
}
|
|
2052
|
-
const
|
|
2053
|
-
class
|
|
2052
|
+
const te = new vo();
|
|
2053
|
+
class No extends g {
|
|
2054
2054
|
constructor() {
|
|
2055
2055
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
2056
2056
|
}
|
|
@@ -2070,8 +2070,8 @@ class vo extends g {
|
|
|
2070
2070
|
), t;
|
|
2071
2071
|
}
|
|
2072
2072
|
}
|
|
2073
|
-
new
|
|
2074
|
-
class
|
|
2073
|
+
new No();
|
|
2074
|
+
class $o extends g {
|
|
2075
2075
|
constructor() {
|
|
2076
2076
|
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
2077
2077
|
{
|
|
@@ -2110,7 +2110,7 @@ class No extends g {
|
|
|
2110
2110
|
T: 9
|
|
2111
2111
|
/* ScalarType.STRING */
|
|
2112
2112
|
},
|
|
2113
|
-
{ no: 12, name: "last_modified", kind: "message", T: () =>
|
|
2113
|
+
{ no: 12, name: "last_modified", kind: "message", T: () => te },
|
|
2114
2114
|
{
|
|
2115
2115
|
no: 13,
|
|
2116
2116
|
name: "version",
|
|
@@ -2151,7 +2151,7 @@ class No extends g {
|
|
|
2151
2151
|
break;
|
|
2152
2152
|
case /* google.protobuf.Timestamp last_modified */
|
|
2153
2153
|
12:
|
|
2154
|
-
r.lastModified =
|
|
2154
|
+
r.lastModified = te.internalBinaryRead(
|
|
2155
2155
|
e,
|
|
2156
2156
|
e.uint32(),
|
|
2157
2157
|
o,
|
|
@@ -2181,7 +2181,7 @@ class No extends g {
|
|
|
2181
2181
|
return r;
|
|
2182
2182
|
}
|
|
2183
2183
|
internalBinaryWrite(e, t, o) {
|
|
2184
|
-
e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified &&
|
|
2184
|
+
e.name !== "" && t.tag(1, h.LengthDelimited).string(e.name), e.size !== 0n && t.tag(2, h.Varint).uint64(e.size), e.isDir !== !1 && t.tag(3, h.Varint).bool(e.isDir), e.fullName !== "" && t.tag(10, h.LengthDelimited).string(e.fullName), e.directory !== "" && t.tag(11, h.LengthDelimited).string(e.directory), e.lastModified && te.internalBinaryWrite(
|
|
2185
2185
|
e.lastModified,
|
|
2186
2186
|
t.tag(12, h.LengthDelimited).fork(),
|
|
2187
2187
|
o
|
|
@@ -2194,8 +2194,8 @@ class No extends g {
|
|
|
2194
2194
|
), t;
|
|
2195
2195
|
}
|
|
2196
2196
|
}
|
|
2197
|
-
const
|
|
2198
|
-
class
|
|
2197
|
+
const oe = new $o();
|
|
2198
|
+
class Bo extends g {
|
|
2199
2199
|
constructor() {
|
|
2200
2200
|
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
2201
2201
|
}
|
|
@@ -2215,8 +2215,8 @@ class $o extends g {
|
|
|
2215
2215
|
), t;
|
|
2216
2216
|
}
|
|
2217
2217
|
}
|
|
2218
|
-
new
|
|
2219
|
-
class
|
|
2218
|
+
new Bo();
|
|
2219
|
+
class Co extends g {
|
|
2220
2220
|
constructor() {
|
|
2221
2221
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Request", [
|
|
2222
2222
|
{
|
|
@@ -2281,8 +2281,8 @@ class Bo extends g {
|
|
|
2281
2281
|
), t;
|
|
2282
2282
|
}
|
|
2283
2283
|
}
|
|
2284
|
-
const
|
|
2285
|
-
class
|
|
2284
|
+
const _o = new Co();
|
|
2285
|
+
class Eo extends g {
|
|
2286
2286
|
constructor() {
|
|
2287
2287
|
super("MiLaboratories.Controller.Shared.LsAPI.List.Response", [
|
|
2288
2288
|
{
|
|
@@ -2290,7 +2290,7 @@ class _o extends g {
|
|
|
2290
2290
|
name: "items",
|
|
2291
2291
|
kind: "message",
|
|
2292
2292
|
repeat: 1,
|
|
2293
|
-
T: () =>
|
|
2293
|
+
T: () => oe
|
|
2294
2294
|
},
|
|
2295
2295
|
{
|
|
2296
2296
|
no: 2,
|
|
@@ -2313,7 +2313,7 @@ class _o extends g {
|
|
|
2313
2313
|
case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
|
|
2314
2314
|
1:
|
|
2315
2315
|
r.items.push(
|
|
2316
|
-
|
|
2316
|
+
oe.internalBinaryRead(e, e.uint32(), o)
|
|
2317
2317
|
);
|
|
2318
2318
|
break;
|
|
2319
2319
|
case /* string delimiter */
|
|
@@ -2340,7 +2340,7 @@ class _o extends g {
|
|
|
2340
2340
|
}
|
|
2341
2341
|
internalBinaryWrite(e, t, o) {
|
|
2342
2342
|
for (let r = 0; r < e.items.length; r++)
|
|
2343
|
-
|
|
2343
|
+
oe.internalBinaryWrite(
|
|
2344
2344
|
e.items[r],
|
|
2345
2345
|
t.tag(1, h.LengthDelimited).fork(),
|
|
2346
2346
|
o
|
|
@@ -2354,14 +2354,14 @@ class _o extends g {
|
|
|
2354
2354
|
), t;
|
|
2355
2355
|
}
|
|
2356
2356
|
}
|
|
2357
|
-
const
|
|
2358
|
-
{ name: "List", options: {}, I:
|
|
2357
|
+
const Oo = new Eo(), ne = new E("MiLaboratories.Controller.Shared.LS", [
|
|
2358
|
+
{ name: "List", options: {}, I: _o, O: Oo }
|
|
2359
2359
|
]);
|
|
2360
|
-
class
|
|
2360
|
+
class Fo {
|
|
2361
2361
|
constructor(e) {
|
|
2362
|
-
d(this, "typeName",
|
|
2363
|
-
d(this, "methods",
|
|
2364
|
-
d(this, "options",
|
|
2362
|
+
d(this, "typeName", ne.typeName);
|
|
2363
|
+
d(this, "methods", ne.methods);
|
|
2364
|
+
d(this, "options", ne.options);
|
|
2365
2365
|
this._transport = e;
|
|
2366
2366
|
}
|
|
2367
2367
|
/**
|
|
@@ -2369,7 +2369,7 @@ class Oo {
|
|
|
2369
2369
|
*/
|
|
2370
2370
|
list(e, t) {
|
|
2371
2371
|
const o = this.methods[0], n = this._transport.mergeOptions(t);
|
|
2372
|
-
return
|
|
2372
|
+
return k(
|
|
2373
2373
|
"unary",
|
|
2374
2374
|
this._transport,
|
|
2375
2375
|
o,
|
|
@@ -2378,10 +2378,10 @@ class Oo {
|
|
|
2378
2378
|
);
|
|
2379
2379
|
}
|
|
2380
2380
|
}
|
|
2381
|
-
class
|
|
2381
|
+
class Wo {
|
|
2382
2382
|
constructor(e, t) {
|
|
2383
2383
|
d(this, "grpcClient");
|
|
2384
|
-
this.logger = t, this.grpcClient = new
|
|
2384
|
+
this.logger = t, this.grpcClient = new Fo(e);
|
|
2385
2385
|
}
|
|
2386
2386
|
close() {
|
|
2387
2387
|
}
|
|
@@ -2391,11 +2391,11 @@ class Fo {
|
|
|
2391
2391
|
resourceId: e.id,
|
|
2392
2392
|
location: t
|
|
2393
2393
|
},
|
|
2394
|
-
|
|
2394
|
+
U(e.type, o)
|
|
2395
2395
|
).response;
|
|
2396
2396
|
}
|
|
2397
2397
|
}
|
|
2398
|
-
class
|
|
2398
|
+
class zo extends g {
|
|
2399
2399
|
constructor() {
|
|
2400
2400
|
super("MiLaboratories.Controller.Shared.StreamingAPI", []);
|
|
2401
2401
|
}
|
|
@@ -2415,8 +2415,8 @@ class Wo extends g {
|
|
|
2415
2415
|
), t;
|
|
2416
2416
|
}
|
|
2417
2417
|
}
|
|
2418
|
-
new
|
|
2419
|
-
class
|
|
2418
|
+
new zo();
|
|
2419
|
+
class xo extends g {
|
|
2420
2420
|
constructor() {
|
|
2421
2421
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamBinary", [
|
|
2422
2422
|
{
|
|
@@ -2507,8 +2507,8 @@ class zo extends g {
|
|
|
2507
2507
|
), t;
|
|
2508
2508
|
}
|
|
2509
2509
|
}
|
|
2510
|
-
const
|
|
2511
|
-
class
|
|
2510
|
+
const Ao = new xo();
|
|
2511
|
+
class Mo extends g {
|
|
2512
2512
|
constructor() {
|
|
2513
2513
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadBinary", [
|
|
2514
2514
|
{
|
|
@@ -2586,8 +2586,8 @@ class Ao extends g {
|
|
|
2586
2586
|
), t;
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
|
-
const
|
|
2590
|
-
class
|
|
2589
|
+
const Ho = new Mo();
|
|
2590
|
+
class jo extends g {
|
|
2591
2591
|
constructor() {
|
|
2592
2592
|
super("MiLaboratories.Controller.Shared.StreamingAPI.StreamText", [
|
|
2593
2593
|
{
|
|
@@ -2690,8 +2690,8 @@ class Ho extends g {
|
|
|
2690
2690
|
), t;
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
|
-
const
|
|
2694
|
-
class
|
|
2693
|
+
const Go = new jo();
|
|
2694
|
+
class Vo extends g {
|
|
2695
2695
|
constructor() {
|
|
2696
2696
|
super("MiLaboratories.Controller.Shared.StreamingAPI.ReadText", [
|
|
2697
2697
|
{
|
|
@@ -2794,8 +2794,8 @@ class Go extends g {
|
|
|
2794
2794
|
), t;
|
|
2795
2795
|
}
|
|
2796
2796
|
}
|
|
2797
|
-
const
|
|
2798
|
-
class
|
|
2797
|
+
const qo = new Vo();
|
|
2798
|
+
class Jo extends g {
|
|
2799
2799
|
constructor() {
|
|
2800
2800
|
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2801
2801
|
{
|
|
@@ -2898,8 +2898,8 @@ class qo extends g {
|
|
|
2898
2898
|
), t;
|
|
2899
2899
|
}
|
|
2900
2900
|
}
|
|
2901
|
-
const
|
|
2902
|
-
class
|
|
2901
|
+
const Zo = new Jo();
|
|
2902
|
+
class Qo extends g {
|
|
2903
2903
|
constructor() {
|
|
2904
2904
|
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2905
2905
|
{
|
|
@@ -2976,48 +2976,48 @@ class Zo extends g {
|
|
|
2976
2976
|
), t;
|
|
2977
2977
|
}
|
|
2978
2978
|
}
|
|
2979
|
-
const
|
|
2979
|
+
const B = new Qo(), re = new E(
|
|
2980
2980
|
"MiLaboratories.Controller.Shared.Streaming",
|
|
2981
2981
|
[
|
|
2982
2982
|
{
|
|
2983
2983
|
name: "StreamBinary",
|
|
2984
2984
|
serverStreaming: !0,
|
|
2985
2985
|
options: {},
|
|
2986
|
-
I:
|
|
2987
|
-
O:
|
|
2986
|
+
I: Ao,
|
|
2987
|
+
O: B
|
|
2988
2988
|
},
|
|
2989
2989
|
{
|
|
2990
2990
|
name: "ReadBinary",
|
|
2991
2991
|
options: {},
|
|
2992
|
-
I:
|
|
2993
|
-
O:
|
|
2992
|
+
I: Ho,
|
|
2993
|
+
O: B
|
|
2994
2994
|
},
|
|
2995
2995
|
{
|
|
2996
2996
|
name: "StreamText",
|
|
2997
2997
|
serverStreaming: !0,
|
|
2998
2998
|
options: {},
|
|
2999
|
-
I:
|
|
3000
|
-
O:
|
|
2999
|
+
I: Go,
|
|
3000
|
+
O: B
|
|
3001
3001
|
},
|
|
3002
3002
|
{
|
|
3003
3003
|
name: "ReadText",
|
|
3004
3004
|
options: {},
|
|
3005
|
-
I:
|
|
3006
|
-
O:
|
|
3005
|
+
I: qo,
|
|
3006
|
+
O: B
|
|
3007
3007
|
},
|
|
3008
3008
|
{
|
|
3009
3009
|
name: "LastLines",
|
|
3010
3010
|
options: {},
|
|
3011
|
-
I:
|
|
3012
|
-
O:
|
|
3011
|
+
I: Zo,
|
|
3012
|
+
O: B
|
|
3013
3013
|
}
|
|
3014
3014
|
]
|
|
3015
3015
|
);
|
|
3016
|
-
class
|
|
3016
|
+
class Xo {
|
|
3017
3017
|
constructor(e) {
|
|
3018
|
-
d(this, "typeName",
|
|
3019
|
-
d(this, "methods",
|
|
3020
|
-
d(this, "options",
|
|
3018
|
+
d(this, "typeName", re.typeName);
|
|
3019
|
+
d(this, "methods", re.methods);
|
|
3020
|
+
d(this, "options", re.options);
|
|
3021
3021
|
this._transport = e;
|
|
3022
3022
|
}
|
|
3023
3023
|
/**
|
|
@@ -3029,7 +3029,7 @@ class Qo {
|
|
|
3029
3029
|
*/
|
|
3030
3030
|
streamBinary(e, t) {
|
|
3031
3031
|
const o = this.methods[0], n = this._transport.mergeOptions(t);
|
|
3032
|
-
return
|
|
3032
|
+
return k(
|
|
3033
3033
|
"serverStreaming",
|
|
3034
3034
|
this._transport,
|
|
3035
3035
|
o,
|
|
@@ -3047,7 +3047,7 @@ class Qo {
|
|
|
3047
3047
|
*/
|
|
3048
3048
|
readBinary(e, t) {
|
|
3049
3049
|
const o = this.methods[1], n = this._transport.mergeOptions(t);
|
|
3050
|
-
return
|
|
3050
|
+
return k(
|
|
3051
3051
|
"unary",
|
|
3052
3052
|
this._transport,
|
|
3053
3053
|
o,
|
|
@@ -3063,7 +3063,7 @@ class Qo {
|
|
|
3063
3063
|
*/
|
|
3064
3064
|
streamText(e, t) {
|
|
3065
3065
|
const o = this.methods[2], n = this._transport.mergeOptions(t);
|
|
3066
|
-
return
|
|
3066
|
+
return k(
|
|
3067
3067
|
"serverStreaming",
|
|
3068
3068
|
this._transport,
|
|
3069
3069
|
o,
|
|
@@ -3081,7 +3081,7 @@ class Qo {
|
|
|
3081
3081
|
*/
|
|
3082
3082
|
readText(e, t) {
|
|
3083
3083
|
const o = this.methods[3], n = this._transport.mergeOptions(t);
|
|
3084
|
-
return
|
|
3084
|
+
return k(
|
|
3085
3085
|
"unary",
|
|
3086
3086
|
this._transport,
|
|
3087
3087
|
o,
|
|
@@ -3103,7 +3103,7 @@ class Qo {
|
|
|
3103
3103
|
*/
|
|
3104
3104
|
lastLines(e, t) {
|
|
3105
3105
|
const o = this.methods[4], n = this._transport.mergeOptions(t);
|
|
3106
|
-
return
|
|
3106
|
+
return k(
|
|
3107
3107
|
"unary",
|
|
3108
3108
|
this._transport,
|
|
3109
3109
|
o,
|
|
@@ -3112,10 +3112,10 @@ class Qo {
|
|
|
3112
3112
|
);
|
|
3113
3113
|
}
|
|
3114
3114
|
}
|
|
3115
|
-
class
|
|
3115
|
+
class Ko {
|
|
3116
3116
|
constructor(e, t, o) {
|
|
3117
3117
|
d(this, "grpcClient");
|
|
3118
|
-
this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new
|
|
3118
|
+
this.grpcTransport = e, this.httpClient = t, this.logger = o, this.grpcClient = new Xo(this.grpcTransport);
|
|
3119
3119
|
}
|
|
3120
3120
|
close() {
|
|
3121
3121
|
}
|
|
@@ -3130,7 +3130,7 @@ class Xo {
|
|
|
3130
3130
|
offset: n,
|
|
3131
3131
|
search: r
|
|
3132
3132
|
},
|
|
3133
|
-
|
|
3133
|
+
U(t, a)
|
|
3134
3134
|
)).response;
|
|
3135
3135
|
}
|
|
3136
3136
|
/** Reads the file forward and returns the text,
|
|
@@ -3139,49 +3139,49 @@ class Xo {
|
|
|
3139
3139
|
async readText({ id: e, type: t }, o, n = 0n, r, a) {
|
|
3140
3140
|
return (await this.grpcClient.readText(
|
|
3141
3141
|
{
|
|
3142
|
-
resourceId:
|
|
3142
|
+
resourceId: j(e),
|
|
3143
3143
|
readLimit: BigInt(o),
|
|
3144
3144
|
offset: n,
|
|
3145
3145
|
search: r
|
|
3146
3146
|
},
|
|
3147
|
-
|
|
3147
|
+
U(t, a)
|
|
3148
3148
|
)).response;
|
|
3149
3149
|
}
|
|
3150
3150
|
}
|
|
3151
|
-
function
|
|
3151
|
+
function kr(s, e, t) {
|
|
3152
3152
|
return e.getDriver({
|
|
3153
3153
|
name: "DownloadBlob",
|
|
3154
|
-
init: (o, n, r) => new
|
|
3154
|
+
init: (o, n, r) => new Po(n, r, s, t)
|
|
3155
3155
|
});
|
|
3156
3156
|
}
|
|
3157
|
-
function
|
|
3157
|
+
function Lr(s, e) {
|
|
3158
3158
|
return s.getDriver({
|
|
3159
3159
|
name: "StreamLogs",
|
|
3160
|
-
init: (t, o, n) => new
|
|
3160
|
+
init: (t, o, n) => new Ko(o, n, e)
|
|
3161
3161
|
});
|
|
3162
3162
|
}
|
|
3163
|
-
function
|
|
3163
|
+
function Pr(s, e) {
|
|
3164
3164
|
return s.getDriver({
|
|
3165
3165
|
name: "UploadProgress",
|
|
3166
|
-
init: (t, o, n) => new
|
|
3166
|
+
init: (t, o, n) => new po(o, n, s, e)
|
|
3167
3167
|
});
|
|
3168
3168
|
}
|
|
3169
|
-
function
|
|
3169
|
+
function Ur(s, e) {
|
|
3170
3170
|
return s.getDriver({
|
|
3171
3171
|
name: "UploadBlob",
|
|
3172
|
-
init: (t, o, n) => new
|
|
3172
|
+
init: (t, o, n) => new qt(o, n, s, e)
|
|
3173
3173
|
});
|
|
3174
3174
|
}
|
|
3175
|
-
function
|
|
3175
|
+
function Yo(s, e) {
|
|
3176
3176
|
return s.getDriver({
|
|
3177
3177
|
name: "LsFiles",
|
|
3178
|
-
init: (t, o, n) => new
|
|
3178
|
+
init: (t, o, n) => new Wo(o, e)
|
|
3179
3179
|
});
|
|
3180
3180
|
}
|
|
3181
|
-
class
|
|
3181
|
+
class en {
|
|
3182
3182
|
constructor(e, t, o, n, r) {
|
|
3183
|
-
d(this, "counter", new
|
|
3184
|
-
d(this, "change", new
|
|
3183
|
+
d(this, "counter", new N());
|
|
3184
|
+
d(this, "change", new $());
|
|
3185
3185
|
d(this, "signalCtl", new AbortController());
|
|
3186
3186
|
d(this, "error");
|
|
3187
3187
|
d(this, "done", !1);
|
|
@@ -3207,20 +3207,20 @@ class Yo {
|
|
|
3207
3207
|
const e = await this.ensureDownloaded();
|
|
3208
3208
|
this.setDone(e), this.change.markChanged();
|
|
3209
3209
|
} catch (e) {
|
|
3210
|
-
throw
|
|
3210
|
+
throw Le(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
|
|
3211
3211
|
}
|
|
3212
3212
|
}
|
|
3213
3213
|
async ensureDownloaded() {
|
|
3214
|
-
if (await
|
|
3214
|
+
if (await ge(T.dirname(this.path)), await fe(this.path))
|
|
3215
3215
|
return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
|
|
3216
3216
|
const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
|
|
3217
|
-
return await
|
|
3218
|
-
const n =
|
|
3217
|
+
return await me(this.logger, this.path, async (o) => {
|
|
3218
|
+
const n = I.toWeb(le.createWriteStream(o, { flags: "wx" }));
|
|
3219
3219
|
await e.pipeTo(n);
|
|
3220
3220
|
}), t;
|
|
3221
3221
|
}
|
|
3222
3222
|
abort(e) {
|
|
3223
|
-
this.signalCtl.abort(new
|
|
3223
|
+
this.signalCtl.abort(new Ve(e));
|
|
3224
3224
|
}
|
|
3225
3225
|
getBlob() {
|
|
3226
3226
|
return this.done ? this.error ? {
|
|
@@ -3244,12 +3244,12 @@ class Yo {
|
|
|
3244
3244
|
this.done = !0, this.error = e;
|
|
3245
3245
|
}
|
|
3246
3246
|
}
|
|
3247
|
-
function
|
|
3248
|
-
return s instanceof
|
|
3247
|
+
function Le(s) {
|
|
3248
|
+
return s instanceof Ve || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
|
|
3249
3249
|
}
|
|
3250
|
-
class
|
|
3250
|
+
class Ve extends Error {
|
|
3251
3251
|
}
|
|
3252
|
-
class
|
|
3252
|
+
class Pe {
|
|
3253
3253
|
constructor(e) {
|
|
3254
3254
|
d(this, "cache", /* @__PURE__ */ new Map());
|
|
3255
3255
|
d(this, "totalSizeBytes", 0);
|
|
@@ -3265,124 +3265,126 @@ class Le {
|
|
|
3265
3265
|
/** Decrements a counter in a cache and if we exceeds
|
|
3266
3266
|
* a soft limit, removes files with zero counters. */
|
|
3267
3267
|
removeFile(e, t) {
|
|
3268
|
-
return
|
|
3268
|
+
return De(this.cache, e).counter.dec(t), this.toDelete();
|
|
3269
3269
|
}
|
|
3270
3270
|
/** Returns what results should be deleted to comply with the soft limit. */
|
|
3271
3271
|
toDelete() {
|
|
3272
3272
|
if (this.totalSizeBytes <= this.softSizeBytes) return [];
|
|
3273
3273
|
const e = [];
|
|
3274
3274
|
let t = 0;
|
|
3275
|
-
return
|
|
3276
|
-
if (this.totalSizeBytes - t <= this.softSizeBytes)
|
|
3277
|
-
|
|
3275
|
+
return ut(this.cache).filter(([o, n]) => n.counter.isZero()).forEach(([o, n]) => {
|
|
3276
|
+
if (this.totalSizeBytes - t <= this.softSizeBytes)
|
|
3277
|
+
return;
|
|
3278
|
+
const r = De(this.cache, o);
|
|
3278
3279
|
t += r.size, e.push(r);
|
|
3279
3280
|
}), e;
|
|
3280
3281
|
}
|
|
3281
3282
|
addCache(e, t) {
|
|
3282
3283
|
const o = this.cache.get(e.path) == null;
|
|
3283
|
-
if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0)
|
|
3284
|
+
if (this.cache.set(e.path, e), e.counter.inc(t), e.size < 0)
|
|
3285
|
+
throw new Error(`empty sizeBytes: ${e}`);
|
|
3284
3286
|
o && (this.totalSizeBytes += e.size);
|
|
3285
3287
|
}
|
|
3286
3288
|
removeCache(e) {
|
|
3287
3289
|
this.cache.delete(e.path), this.totalSizeBytes -= e.size;
|
|
3288
3290
|
}
|
|
3289
3291
|
}
|
|
3290
|
-
const
|
|
3291
|
-
function
|
|
3292
|
+
const qe = /^blob\+local:\/\/download\/(?<path>.*)#(?<signature>.*)$/;
|
|
3293
|
+
function tn(s, e) {
|
|
3292
3294
|
return `blob+local://download/${s}#${e.sign(s)}`;
|
|
3293
3295
|
}
|
|
3294
|
-
function
|
|
3295
|
-
return !!s.match(
|
|
3296
|
+
function on(s) {
|
|
3297
|
+
return !!s.match(qe);
|
|
3296
3298
|
}
|
|
3297
|
-
function
|
|
3298
|
-
const t = s.match(
|
|
3299
|
+
function se(s, e) {
|
|
3300
|
+
const t = s.match(qe);
|
|
3299
3301
|
if (t === null)
|
|
3300
3302
|
throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
3301
3303
|
const { path: o, signature: n } = t.groups;
|
|
3302
3304
|
return e.verify(o, n, `Signature verification failed for: ${s}`), { path: o, signature: n };
|
|
3303
3305
|
}
|
|
3304
|
-
const
|
|
3306
|
+
const nn = V({
|
|
3305
3307
|
kv: {
|
|
3306
|
-
"ctl/file/blobInfo":
|
|
3307
|
-
sizeBytes:
|
|
3308
|
+
"ctl/file/blobInfo": L.object({
|
|
3309
|
+
sizeBytes: L.coerce.number()
|
|
3308
3310
|
})
|
|
3309
3311
|
}
|
|
3310
3312
|
});
|
|
3311
|
-
function
|
|
3313
|
+
function rn(s) {
|
|
3312
3314
|
return s.kv["ctl/file/blobInfo"].sizeBytes;
|
|
3313
3315
|
}
|
|
3314
|
-
const
|
|
3316
|
+
const J = L.object({
|
|
3315
3317
|
/** Local file path, to take data for upload */
|
|
3316
|
-
localPath:
|
|
3318
|
+
localPath: L.string(),
|
|
3317
3319
|
/** Path signature, to check this data was generated by us */
|
|
3318
|
-
pathSignature:
|
|
3320
|
+
pathSignature: L.string(),
|
|
3319
3321
|
/** File size in bytes */
|
|
3320
|
-
sizeBytes:
|
|
3322
|
+
sizeBytes: L.string(),
|
|
3321
3323
|
/** Modification time unix timestamp in seconds */
|
|
3322
|
-
modificationTime:
|
|
3323
|
-
}),
|
|
3324
|
+
modificationTime: L.string()
|
|
3325
|
+
}), Je = L.object({
|
|
3324
3326
|
/** Pl storage id */
|
|
3325
|
-
storageId:
|
|
3327
|
+
storageId: L.string(),
|
|
3326
3328
|
/** Path inside storage */
|
|
3327
|
-
path:
|
|
3328
|
-
}),
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
]),
|
|
3332
|
-
data:
|
|
3329
|
+
path: L.string()
|
|
3330
|
+
}), Dr = L.union([
|
|
3331
|
+
J,
|
|
3332
|
+
Je
|
|
3333
|
+
]), sn = V({
|
|
3334
|
+
data: J,
|
|
3333
3335
|
fields: {
|
|
3334
3336
|
blob: !1
|
|
3335
3337
|
}
|
|
3336
|
-
}),
|
|
3338
|
+
}), an = V({
|
|
3337
3339
|
fields: {
|
|
3338
3340
|
incarnation: !1
|
|
3339
3341
|
}
|
|
3340
|
-
}),
|
|
3341
|
-
function
|
|
3342
|
+
}), Ze = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
|
|
3343
|
+
function ln(s, e) {
|
|
3342
3344
|
const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
|
|
3343
3345
|
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
3344
3346
|
}
|
|
3345
|
-
function
|
|
3346
|
-
return !!s.match(
|
|
3347
|
+
function cn(s) {
|
|
3348
|
+
return !!s.match(Ze);
|
|
3347
3349
|
}
|
|
3348
|
-
function
|
|
3349
|
-
const t = s.match(
|
|
3350
|
+
function dn(s, e) {
|
|
3351
|
+
const t = s.match(Ze);
|
|
3350
3352
|
if (t === null)
|
|
3351
3353
|
throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
3352
3354
|
const { content: o, resourceType: n, resourceVersion: r, resourceId: a, signature: i } = t.groups;
|
|
3353
3355
|
return e.verify(o, i, `Signature verification failed for ${s}`), {
|
|
3354
|
-
id:
|
|
3356
|
+
id: pe(BigInt(a)),
|
|
3355
3357
|
type: { name: n, version: r }
|
|
3356
3358
|
};
|
|
3357
3359
|
}
|
|
3358
|
-
function
|
|
3360
|
+
function Qe(s, e) {
|
|
3359
3361
|
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)}`;
|
|
3360
3362
|
}
|
|
3361
|
-
const
|
|
3362
|
-
function
|
|
3363
|
-
return Qe.test(s);
|
|
3364
|
-
}
|
|
3365
|
-
const Xe = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3366
|
-
function dn(s) {
|
|
3363
|
+
const Xe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3364
|
+
function M(s) {
|
|
3367
3365
|
return Xe.test(s);
|
|
3368
3366
|
}
|
|
3369
|
-
|
|
3367
|
+
const Ke = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3368
|
+
function hn(s) {
|
|
3369
|
+
return Ke.test(s);
|
|
3370
|
+
}
|
|
3371
|
+
function H(s) {
|
|
3370
3372
|
let e;
|
|
3371
|
-
if (
|
|
3372
|
-
e = s.match(Qe);
|
|
3373
|
-
else if (dn(s))
|
|
3373
|
+
if (M(s))
|
|
3374
3374
|
e = s.match(Xe);
|
|
3375
|
+
else if (hn(s))
|
|
3376
|
+
e = s.match(Ke);
|
|
3375
3377
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
3376
3378
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
3377
3379
|
const { resourceType: t, resourceVersion: o, resourceId: n } = e.groups;
|
|
3378
3380
|
return {
|
|
3379
|
-
id:
|
|
3381
|
+
id: pe(BigInt(n)),
|
|
3380
3382
|
type: { name: t, version: o }
|
|
3381
3383
|
};
|
|
3382
3384
|
}
|
|
3383
|
-
class
|
|
3385
|
+
class Ue extends Error {
|
|
3384
3386
|
}
|
|
3385
|
-
class
|
|
3387
|
+
class un {
|
|
3386
3388
|
constructor(e) {
|
|
3387
3389
|
d(this, "updating");
|
|
3388
3390
|
this.onUpdate = e;
|
|
@@ -3399,9 +3401,9 @@ class hn {
|
|
|
3399
3401
|
})());
|
|
3400
3402
|
}
|
|
3401
3403
|
}
|
|
3402
|
-
class
|
|
3404
|
+
class Rr {
|
|
3403
3405
|
constructor(e, t, o, n, r, a) {
|
|
3404
|
-
/** Represents a
|
|
3406
|
+
/** Represents a unique key to the path of a blob as a map. */
|
|
3405
3407
|
d(this, "idToDownload", /* @__PURE__ */ new Map());
|
|
3406
3408
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3407
3409
|
* file that should be kept. */
|
|
@@ -3412,41 +3414,42 @@ class Dr {
|
|
|
3412
3414
|
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3413
3415
|
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3414
3416
|
d(this, "saveDir");
|
|
3415
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new
|
|
3416
|
-
}
|
|
3417
|
-
getDownloadedBlob(e, t) {
|
|
3418
|
-
if (t === void 0)
|
|
3419
|
-
|
|
3420
|
-
t
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3417
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = o, this.signer = r, this.cache = new Pe(a.cacheSoftSizeBytes), this.downloadQueue = new G(this.logger, a.nConcurrentDownloads), this.saveDir = T.resolve(n);
|
|
3418
|
+
}
|
|
3419
|
+
getDownloadedBlob(e, t, o, n) {
|
|
3420
|
+
if (t === void 0)
|
|
3421
|
+
return y.make((l) => this.getDownloadedBlob(e, l, o, n));
|
|
3422
|
+
const r = S(e, t), a = w(r.id, o, n), i = D();
|
|
3423
|
+
t.addOnDestroy(() => this.releaseBlob(a, i));
|
|
3424
|
+
const c = this.getDownloadedBlobNoCtx(t.watcher, r, i, o, n);
|
|
3425
|
+
return c == null && t.markUnstable("download blob is still undefined"), c;
|
|
3426
|
+
}
|
|
3427
|
+
getDownloadedBlobNoCtx(e, t, o, n, r) {
|
|
3428
|
+
C("getDownloadedBlob", t.type);
|
|
3429
|
+
let a = this.idToDownload.get(w(t.id, n, r));
|
|
3430
|
+
if (a === void 0) {
|
|
3431
|
+
const c = this.setNewDownloadTask(t);
|
|
3429
3432
|
this.downloadQueue.push({
|
|
3430
|
-
fn: () => this.downloadBlob(
|
|
3431
|
-
recoverableErrorPredicate: (
|
|
3432
|
-
}),
|
|
3433
|
+
fn: () => this.downloadBlob(c, o),
|
|
3434
|
+
recoverableErrorPredicate: (l) => !Le(l)
|
|
3435
|
+
}), a = c;
|
|
3433
3436
|
}
|
|
3434
|
-
|
|
3435
|
-
const
|
|
3436
|
-
if (
|
|
3437
|
-
if (
|
|
3438
|
-
throw
|
|
3437
|
+
a.attach(e, o);
|
|
3438
|
+
const i = a.getBlob();
|
|
3439
|
+
if (i.done) {
|
|
3440
|
+
if (i.result.ok) return i.result.value;
|
|
3441
|
+
throw i.result.error;
|
|
3439
3442
|
}
|
|
3440
3443
|
}
|
|
3441
|
-
setNewDownloadTask(e) {
|
|
3442
|
-
const
|
|
3444
|
+
setNewDownloadTask(e, t, o) {
|
|
3445
|
+
const n = T.resolve(this.saveDir, w(e.id, t, o)), r = new en(
|
|
3443
3446
|
this.logger,
|
|
3444
3447
|
this.clientDownload,
|
|
3445
3448
|
e,
|
|
3446
|
-
|
|
3447
|
-
|
|
3449
|
+
n,
|
|
3450
|
+
tn(n, this.signer)
|
|
3448
3451
|
);
|
|
3449
|
-
return this.idToDownload.set(e.id, o),
|
|
3452
|
+
return this.idToDownload.set(w(e.id, t, o), r), r;
|
|
3450
3453
|
}
|
|
3451
3454
|
async downloadBlob(e, t) {
|
|
3452
3455
|
await e.download();
|
|
@@ -3454,27 +3457,27 @@ class Dr {
|
|
|
3454
3457
|
o.done && o.result.ok && this.cache.addCache(e, t);
|
|
3455
3458
|
}
|
|
3456
3459
|
getOnDemandBlob(e, t) {
|
|
3457
|
-
if (t === void 0) return
|
|
3458
|
-
const o =
|
|
3460
|
+
if (t === void 0) return y.make((a) => this.getOnDemandBlob(e, a));
|
|
3461
|
+
const o = O(e) ? A(e, nn, t) : e, n = D();
|
|
3459
3462
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
|
|
3460
3463
|
}
|
|
3461
3464
|
getOnDemandBlobNoCtx(e, t) {
|
|
3462
|
-
|
|
3463
|
-
let o = this.idToOnDemand.get(e.id);
|
|
3464
|
-
return o === void 0 && (o = new
|
|
3465
|
+
C("getOnDemandBlob", e.type);
|
|
3466
|
+
let o = this.idToOnDemand.get(w(e.id));
|
|
3467
|
+
return o === void 0 && (o = new pn(rn(e), ln(e, this.signer)), this.idToOnDemand.set(w(e.id), o)), o.attach(t), o.getHandle();
|
|
3465
3468
|
}
|
|
3466
3469
|
/** Gets a path from a handle. */
|
|
3467
3470
|
getLocalPath(e) {
|
|
3468
|
-
const { path: t } =
|
|
3471
|
+
const { path: t } = se(e, this.signer);
|
|
3469
3472
|
return t;
|
|
3470
3473
|
}
|
|
3471
3474
|
/** Gets a content of a blob by a handle. */
|
|
3472
3475
|
async getContent(e) {
|
|
3473
|
-
if (
|
|
3474
|
-
return await
|
|
3475
|
-
if (
|
|
3476
|
-
const t =
|
|
3477
|
-
return await
|
|
3476
|
+
if (on(e))
|
|
3477
|
+
return await fn(this.getLocalPath(e));
|
|
3478
|
+
if (cn(e)) {
|
|
3479
|
+
const t = dn(e, this.signer), { content: o } = await this.clientDownload.downloadBlob(t);
|
|
3480
|
+
return await Ee(o);
|
|
3478
3481
|
}
|
|
3479
3482
|
throw new Error("Malformed remote handle");
|
|
3480
3483
|
}
|
|
@@ -3483,7 +3486,7 @@ class Dr {
|
|
|
3483
3486
|
* Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
|
|
3484
3487
|
*/
|
|
3485
3488
|
getComputableContent(e) {
|
|
3486
|
-
return
|
|
3489
|
+
return y.make(
|
|
3487
3490
|
(t) => this.getDownloadedBlob(e, t),
|
|
3488
3491
|
{
|
|
3489
3492
|
postprocessValue: (t) => t ? this.getContent(t.handle) : void 0
|
|
@@ -3491,21 +3494,21 @@ class Dr {
|
|
|
3491
3494
|
).withStableType();
|
|
3492
3495
|
}
|
|
3493
3496
|
getLastLogs(e, t, o) {
|
|
3494
|
-
if (o == null) return
|
|
3495
|
-
const n =
|
|
3496
|
-
o.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3497
|
+
if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
|
|
3498
|
+
const n = S(e, o), r = D();
|
|
3499
|
+
o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
|
|
3497
3500
|
const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
|
|
3498
3501
|
return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
|
|
3499
3502
|
}
|
|
3500
3503
|
getLastLogsNoCtx(e, t, o, n) {
|
|
3501
|
-
|
|
3504
|
+
C("getLastLogs", t.type);
|
|
3502
3505
|
const r = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3503
3506
|
if (r == null) return;
|
|
3504
|
-
const { path: a } =
|
|
3505
|
-
let i = this.idToLastLines.get(t.id);
|
|
3507
|
+
const { path: a } = se(r.handle, this.signer);
|
|
3508
|
+
let i = this.idToLastLines.get(w(t.id));
|
|
3506
3509
|
if (i == null) {
|
|
3507
|
-
const l = new
|
|
3508
|
-
this.idToLastLines.set(t.id, l), i = l;
|
|
3510
|
+
const l = new Se(a, o);
|
|
3511
|
+
this.idToLastLines.set(w(t.id), l), i = l;
|
|
3509
3512
|
}
|
|
3510
3513
|
const c = i.getOrSchedule(e);
|
|
3511
3514
|
if (c.error) throw c.error;
|
|
@@ -3513,9 +3516,9 @@ class Dr {
|
|
|
3513
3516
|
}
|
|
3514
3517
|
getProgressLog(e, t, o) {
|
|
3515
3518
|
if (o == null)
|
|
3516
|
-
return
|
|
3517
|
-
const n =
|
|
3518
|
-
o.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3519
|
+
return y.make((i) => this.getProgressLog(e, t, i));
|
|
3520
|
+
const n = S(e, o), r = D();
|
|
3521
|
+
o.addOnDestroy(() => this.releaseBlob(w(n.id), r));
|
|
3519
3522
|
const a = this.getProgressLogNoCtx(
|
|
3520
3523
|
o.watcher,
|
|
3521
3524
|
n,
|
|
@@ -3525,30 +3528,30 @@ class Dr {
|
|
|
3525
3528
|
return a === void 0 && o.markUnstable("either a file was not downloaded or a progress log was not read"), a;
|
|
3526
3529
|
}
|
|
3527
3530
|
getProgressLogNoCtx(e, t, o, n) {
|
|
3528
|
-
|
|
3531
|
+
C("getProgressLog", t.type);
|
|
3529
3532
|
const r = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3530
3533
|
if (r == null) return;
|
|
3531
|
-
const { path: a } =
|
|
3532
|
-
let i = this.idToProgressLog.get(t.id);
|
|
3534
|
+
const { path: a } = se(r.handle, this.signer);
|
|
3535
|
+
let i = this.idToProgressLog.get(w(t.id));
|
|
3533
3536
|
if (i == null) {
|
|
3534
|
-
const l = new
|
|
3535
|
-
this.idToProgressLog.set(t.id, l), i = l;
|
|
3537
|
+
const l = new Se(a, 1, o);
|
|
3538
|
+
this.idToProgressLog.set(w(t.id), l), i = l;
|
|
3536
3539
|
}
|
|
3537
3540
|
const c = i.getOrSchedule(e);
|
|
3538
3541
|
if (c.error) throw c.error;
|
|
3539
3542
|
return c.log;
|
|
3540
3543
|
}
|
|
3541
3544
|
getLogHandle(e, t) {
|
|
3542
|
-
if (t == null) return
|
|
3543
|
-
const o =
|
|
3545
|
+
if (t == null) return y.make((n) => this.getLogHandle(e, n));
|
|
3546
|
+
const o = S(e, t);
|
|
3544
3547
|
return this.getLogHandleNoCtx(o);
|
|
3545
3548
|
}
|
|
3546
3549
|
getLogHandleNoCtx(e) {
|
|
3547
|
-
return
|
|
3550
|
+
return C("getLogHandle", e.type), Qe(!1, e);
|
|
3548
3551
|
}
|
|
3549
3552
|
async lastLines(e, t, o, n) {
|
|
3550
3553
|
const r = await this.clientLogs.lastLines(
|
|
3551
|
-
|
|
3554
|
+
H(e),
|
|
3552
3555
|
t,
|
|
3553
3556
|
BigInt(o ?? 0),
|
|
3554
3557
|
n
|
|
@@ -3563,7 +3566,7 @@ class Dr {
|
|
|
3563
3566
|
}
|
|
3564
3567
|
async readText(e, t, o, n) {
|
|
3565
3568
|
const r = await this.clientLogs.readText(
|
|
3566
|
-
|
|
3569
|
+
H(e),
|
|
3567
3570
|
t,
|
|
3568
3571
|
BigInt(o ?? 0),
|
|
3569
3572
|
n
|
|
@@ -3585,22 +3588,22 @@ class Dr {
|
|
|
3585
3588
|
n.map(async (r) => {
|
|
3586
3589
|
await m.rm(r.path), this.cache.removeCache(r), this.removeTask(
|
|
3587
3590
|
r,
|
|
3588
|
-
`the task ${
|
|
3591
|
+
`the task ${b(r.info())} was removedfrom cache along with ${b(n.map((a) => a.info()))}`
|
|
3589
3592
|
);
|
|
3590
3593
|
})
|
|
3591
3594
|
);
|
|
3592
3595
|
} else
|
|
3593
3596
|
o.counter.dec(t) && this.removeTask(
|
|
3594
3597
|
o,
|
|
3595
|
-
`the task ${
|
|
3598
|
+
`the task ${b(o.info())} was removed from cache`
|
|
3596
3599
|
);
|
|
3597
3600
|
}
|
|
3598
3601
|
removeTask(e, t) {
|
|
3599
|
-
e.abort(t), e.change.markChanged(), this.idToDownload.delete(e.rInfo.id), this.idToLastLines.delete(e.rInfo.id), this.idToProgressLog.delete(e.rInfo.id);
|
|
3602
|
+
e.abort(t), e.change.markChanged(), this.idToDownload.delete(w(e.rInfo.id)), this.idToLastLines.delete(w(e.rInfo.id)), this.idToProgressLog.delete(w(e.rInfo.id));
|
|
3600
3603
|
}
|
|
3601
3604
|
async releaseOnDemandBlob(e, t) {
|
|
3602
3605
|
var n;
|
|
3603
|
-
(((n = this.idToOnDemand.get(e)) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(e);
|
|
3606
|
+
(((n = this.idToOnDemand.get(w(e))) == null ? void 0 : n.release(t)) ?? !1) && this.idToOnDemand.delete(w(e));
|
|
3604
3607
|
}
|
|
3605
3608
|
/** Removes all files from a hard drive. */
|
|
3606
3609
|
async releaseAll() {
|
|
@@ -3608,13 +3611,10 @@ class Dr {
|
|
|
3608
3611
|
this.idToDownload.delete(t), e.change.markChanged();
|
|
3609
3612
|
});
|
|
3610
3613
|
}
|
|
3611
|
-
getFilePath(e) {
|
|
3612
|
-
return b.resolve(this.saveDir, String(BigInt(e)));
|
|
3613
|
-
}
|
|
3614
3614
|
}
|
|
3615
|
-
class
|
|
3615
|
+
class pn {
|
|
3616
3616
|
constructor(e, t) {
|
|
3617
|
-
d(this, "counter", new
|
|
3617
|
+
d(this, "counter", new N());
|
|
3618
3618
|
this.size = e, this.handle = t;
|
|
3619
3619
|
}
|
|
3620
3620
|
getHandle() {
|
|
@@ -3627,13 +3627,13 @@ class un {
|
|
|
3627
3627
|
return this.counter.dec(e);
|
|
3628
3628
|
}
|
|
3629
3629
|
}
|
|
3630
|
-
class
|
|
3630
|
+
class Se {
|
|
3631
3631
|
constructor(e, t, o) {
|
|
3632
3632
|
d(this, "updater");
|
|
3633
3633
|
d(this, "log");
|
|
3634
|
-
d(this, "change", new
|
|
3634
|
+
d(this, "change", new $());
|
|
3635
3635
|
d(this, "error");
|
|
3636
|
-
this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new
|
|
3636
|
+
this.path = e, this.lines = t, this.patternToSearch = o, this.updater = new un(async () => this.update());
|
|
3637
3637
|
}
|
|
3638
3638
|
getOrSchedule(e) {
|
|
3639
3639
|
return this.change.attachWatcher(e), this.updater.schedule(), {
|
|
@@ -3643,7 +3643,7 @@ class Re {
|
|
|
3643
3643
|
}
|
|
3644
3644
|
async update() {
|
|
3645
3645
|
try {
|
|
3646
|
-
const e = await
|
|
3646
|
+
const e = await gn(this.path, this.lines, this.patternToSearch);
|
|
3647
3647
|
this.log != e && this.change.markChanged(), this.log = e;
|
|
3648
3648
|
} catch (e) {
|
|
3649
3649
|
if (e.name == "RpcError" && e.code == "NOT_FOUND") {
|
|
@@ -3654,54 +3654,57 @@ class Re {
|
|
|
3654
3654
|
}
|
|
3655
3655
|
}
|
|
3656
3656
|
}
|
|
3657
|
-
function
|
|
3658
|
-
const o =
|
|
3657
|
+
function gn(s, e, t) {
|
|
3658
|
+
const o = ye.createReadStream(s), n = new I();
|
|
3659
3659
|
return new Promise((r, a) => {
|
|
3660
|
-
const i =
|
|
3660
|
+
const i = yt.createInterface(o, n), c = new ft();
|
|
3661
3661
|
i.on("line", function(l) {
|
|
3662
3662
|
t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
|
|
3663
3663
|
}), i.on("error", a), i.on("close", function() {
|
|
3664
|
-
r(c.toArray().join(
|
|
3664
|
+
r(c.toArray().join(Re.EOL) + Re.EOL);
|
|
3665
3665
|
});
|
|
3666
3666
|
});
|
|
3667
3667
|
}
|
|
3668
|
-
async function
|
|
3669
|
-
return await
|
|
3668
|
+
async function fn(s) {
|
|
3669
|
+
return await Ee(be.toWeb(ye.createReadStream(s)));
|
|
3670
3670
|
}
|
|
3671
|
-
function
|
|
3671
|
+
function C(s, e) {
|
|
3672
3672
|
if (!e.name.startsWith("Blob/")) {
|
|
3673
3673
|
let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
|
|
3674
|
-
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new
|
|
3674
|
+
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new Ue(t);
|
|
3675
3675
|
}
|
|
3676
3676
|
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
const t = E(s) ? e.accessor(s).node() : Oe(s) ? s.node() : s;
|
|
3680
|
-
return x(t, fn);
|
|
3677
|
+
function w(s, e, t) {
|
|
3678
|
+
return e !== void 0 && t !== void 0 ? `${BigInt(s)}_${e}-${t}` : `${BigInt(s)}`;
|
|
3681
3679
|
}
|
|
3682
|
-
|
|
3683
|
-
|
|
3680
|
+
const mn = V({});
|
|
3681
|
+
function wn(s, e) {
|
|
3682
|
+
const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
|
|
3683
|
+
return A(t, mn);
|
|
3684
|
+
}
|
|
3685
|
+
function yn(s, e, t) {
|
|
3686
|
+
const o = P.relative(e, t);
|
|
3684
3687
|
return `plblob+folder://${s.sign(o)}.${o}.blob`;
|
|
3685
3688
|
}
|
|
3686
|
-
function
|
|
3689
|
+
function bn(s) {
|
|
3687
3690
|
return new URL(s).protocol == "plblob+folder:";
|
|
3688
3691
|
}
|
|
3689
|
-
function
|
|
3692
|
+
function Tn(s, e, t) {
|
|
3690
3693
|
const o = new URL(e), [n, r, a] = o.host.split(".");
|
|
3691
3694
|
s.verify(r, n, `signature verification failed for url: ${e}, subfolder: ${r}`);
|
|
3692
|
-
let i =
|
|
3693
|
-
return (o.pathname == "" || o.pathname == "/") && (i =
|
|
3695
|
+
let i = kn(P.join(t, `${r}`), o.pathname.slice(1));
|
|
3696
|
+
return (o.pathname == "" || o.pathname == "/") && (i = P.join(i, "index.html")), P.resolve(i);
|
|
3694
3697
|
}
|
|
3695
|
-
function
|
|
3696
|
-
const t =
|
|
3698
|
+
function kn(s, e) {
|
|
3699
|
+
const t = P.resolve(s, e), o = P.resolve(s);
|
|
3697
3700
|
if (!t.startsWith(o))
|
|
3698
3701
|
throw new Error("Path validation failed.");
|
|
3699
3702
|
return t;
|
|
3700
3703
|
}
|
|
3701
|
-
class
|
|
3704
|
+
class Ln {
|
|
3702
3705
|
constructor(e, t, o, n, r, a, i) {
|
|
3703
|
-
d(this, "counter", new
|
|
3704
|
-
d(this, "change", new
|
|
3706
|
+
d(this, "counter", new N());
|
|
3707
|
+
d(this, "change", new $());
|
|
3705
3708
|
d(this, "signalCtl", new AbortController());
|
|
3706
3709
|
d(this, "error");
|
|
3707
3710
|
d(this, "done", !1);
|
|
@@ -3728,10 +3731,10 @@ class kn {
|
|
|
3728
3731
|
async download() {
|
|
3729
3732
|
try {
|
|
3730
3733
|
const e = await this.downloadAndDecompress(this.signalCtl.signal);
|
|
3731
|
-
this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${
|
|
3734
|
+
this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${b(this.info())}`);
|
|
3732
3735
|
} catch (e) {
|
|
3733
|
-
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${
|
|
3734
|
-
this.setError(e), this.change.markChanged(), await
|
|
3736
|
+
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${b(this.info())}`), Pn(e)) {
|
|
3737
|
+
this.setError(e), this.change.markChanged(), await de(this.path);
|
|
3735
3738
|
return;
|
|
3736
3739
|
}
|
|
3737
3740
|
throw e;
|
|
@@ -3739,72 +3742,72 @@ class kn {
|
|
|
3739
3742
|
}
|
|
3740
3743
|
/** Does the download part and keeps a state of the process. */
|
|
3741
3744
|
async downloadAndDecompress(e) {
|
|
3742
|
-
if (this.state = {}, this.state.parentDir =
|
|
3743
|
-
return await
|
|
3745
|
+
if (this.state = {}, this.state.parentDir = P.dirname(this.path), await ge(this.state.parentDir), this.state.fileExisted = await fe(this.path), this.state.fileExisted)
|
|
3746
|
+
return await Ye(this.path);
|
|
3744
3747
|
const { content: t, size: o } = await this.clientDownload.downloadBlob(
|
|
3745
3748
|
this.rInfo,
|
|
3746
3749
|
{},
|
|
3747
3750
|
e
|
|
3748
3751
|
);
|
|
3749
|
-
return this.state.downloaded = !0, await
|
|
3752
|
+
return this.state.downloaded = !0, await me(this.logger, this.path, async (n) => {
|
|
3750
3753
|
switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
|
|
3751
3754
|
case "tar":
|
|
3752
3755
|
await m.mkdir(n);
|
|
3753
|
-
const r =
|
|
3756
|
+
const r = I.toWeb(ce.extract(n));
|
|
3754
3757
|
await t.pipeTo(r, { signal: e });
|
|
3755
3758
|
return;
|
|
3756
3759
|
case "tgz":
|
|
3757
3760
|
await m.mkdir(n);
|
|
3758
|
-
const a =
|
|
3761
|
+
const a = _e.toWeb(We.createGunzip()), i = I.toWeb(ce.extract(n));
|
|
3759
3762
|
await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
|
|
3760
3763
|
return;
|
|
3761
3764
|
case "zip":
|
|
3762
3765
|
this.state.zipPath = this.path + ".zip";
|
|
3763
|
-
const c =
|
|
3764
|
-
await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await
|
|
3766
|
+
const c = I.toWeb(le.createWriteStream(this.state.zipPath));
|
|
3767
|
+
await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await bt(this.state.zipPath, n, {
|
|
3765
3768
|
filter: (l) => !l.path.endsWith("/")
|
|
3766
|
-
}), this.state.zipDecompressed = !0, await
|
|
3769
|
+
}), this.state.zipDecompressed = !0, await le.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
|
|
3767
3770
|
return;
|
|
3768
3771
|
default:
|
|
3769
|
-
|
|
3772
|
+
ht(this.format);
|
|
3770
3773
|
}
|
|
3771
3774
|
}), this.state.pathCreated = !0, o;
|
|
3772
3775
|
}
|
|
3773
3776
|
getURL() {
|
|
3774
|
-
if (this.done) return { url:
|
|
3777
|
+
if (this.done) return { url: j(this.url) };
|
|
3775
3778
|
if (this.error) return { error: this.error };
|
|
3776
3779
|
}
|
|
3777
3780
|
setDone(e) {
|
|
3778
|
-
this.done = !0, this.size = e, this.url =
|
|
3781
|
+
this.done = !0, this.size = e, this.url = yn(this.signer, this.saveDir, this.path);
|
|
3779
3782
|
}
|
|
3780
3783
|
setError(e) {
|
|
3781
3784
|
this.error = String(e);
|
|
3782
3785
|
}
|
|
3783
3786
|
abort(e) {
|
|
3784
|
-
this.signalCtl.abort(new
|
|
3787
|
+
this.signalCtl.abort(new et(e));
|
|
3785
3788
|
}
|
|
3786
3789
|
}
|
|
3787
|
-
async function
|
|
3790
|
+
async function Ye(s) {
|
|
3788
3791
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
3789
3792
|
return (await Promise.all(
|
|
3790
3793
|
e.map(async (o) => {
|
|
3791
|
-
const n =
|
|
3792
|
-
return o.isDirectory() ? await
|
|
3794
|
+
const n = P.join(s, o.name);
|
|
3795
|
+
return o.isDirectory() ? await Ye(n) : (await m.stat(n)).size;
|
|
3793
3796
|
})
|
|
3794
3797
|
)).reduce((o, n) => o + n, 0);
|
|
3795
3798
|
}
|
|
3796
|
-
async function
|
|
3799
|
+
async function de(s) {
|
|
3797
3800
|
await m.rm(s, { recursive: !0, force: !0 });
|
|
3798
3801
|
}
|
|
3799
|
-
let
|
|
3802
|
+
let et = class extends Error {
|
|
3800
3803
|
};
|
|
3801
|
-
function
|
|
3802
|
-
return s instanceof
|
|
3804
|
+
function Pn(s) {
|
|
3805
|
+
return s instanceof et || s instanceof q || s instanceof ke || s instanceof Te || (s == null ? void 0 : s.code) == "ENOENT" || s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED") || String(s).includes("incorrect header check");
|
|
3803
3806
|
}
|
|
3804
|
-
function
|
|
3807
|
+
function F(s, e) {
|
|
3805
3808
|
return `id:${String(BigInt(s))}-${e}`;
|
|
3806
3809
|
}
|
|
3807
|
-
class
|
|
3810
|
+
class Ir {
|
|
3808
3811
|
constructor(e, t, o, n, r = {
|
|
3809
3812
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
3810
3813
|
nConcurrentDownloads: 50
|
|
@@ -3814,13 +3817,13 @@ class Sr {
|
|
|
3814
3817
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
3815
3818
|
* file that should be kept. */
|
|
3816
3819
|
d(this, "cache");
|
|
3817
|
-
this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new
|
|
3820
|
+
this.logger = e, this.signer = t, this.clientDownload = o, this.saveDir = n, this.opts = r, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads, {
|
|
3818
3821
|
type: "exponentialWithMaxDelayBackoff",
|
|
3819
3822
|
initialDelay: 1e4,
|
|
3820
3823
|
maxDelay: 3e4,
|
|
3821
3824
|
backoffMultiplier: 1.5,
|
|
3822
3825
|
jitter: 0.5
|
|
3823
|
-
}), this.cache = new
|
|
3826
|
+
}), this.cache = new Pe(this.opts.cacheSoftSizeBytes);
|
|
3824
3827
|
}
|
|
3825
3828
|
info() {
|
|
3826
3829
|
return {
|
|
@@ -3835,14 +3838,14 @@ class Sr {
|
|
|
3835
3838
|
* @returns full path to the referenced file
|
|
3836
3839
|
*/
|
|
3837
3840
|
getPathForCustomProtocol(e) {
|
|
3838
|
-
if (
|
|
3839
|
-
return
|
|
3841
|
+
if (bn(e))
|
|
3842
|
+
return Tn(this.signer, e, this.saveDir);
|
|
3840
3843
|
throw new Error(`getPathForCustomProtocol: ${e} is invalid`);
|
|
3841
3844
|
}
|
|
3842
3845
|
extractArchiveAndGetURL(e, t, o) {
|
|
3843
3846
|
if (o === void 0)
|
|
3844
|
-
return
|
|
3845
|
-
const n =
|
|
3847
|
+
return y.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
3848
|
+
const n = O(e) ? wn(e, o) : e, r = D();
|
|
3846
3849
|
o.addOnDestroy(() => this.releasePath(n.id, t, r));
|
|
3847
3850
|
const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
|
|
3848
3851
|
if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
|
|
@@ -3852,13 +3855,13 @@ class Sr {
|
|
|
3852
3855
|
return a == null ? void 0 : a.url;
|
|
3853
3856
|
}
|
|
3854
3857
|
extractArchiveAndGetURLNoCtx(e, t, o, n) {
|
|
3855
|
-
const r = this.idToDownload.get(
|
|
3858
|
+
const r = this.idToDownload.get(F(e.id, t));
|
|
3856
3859
|
if (r != null)
|
|
3857
3860
|
return r.attach(o, n), r.getURL();
|
|
3858
3861
|
const a = this.setNewTask(o, e, t, n);
|
|
3859
3862
|
return this.downloadQueue.push({
|
|
3860
3863
|
fn: async () => this.downloadUrl(a, n),
|
|
3861
|
-
recoverableErrorPredicate: (i) => !
|
|
3864
|
+
recoverableErrorPredicate: (i) => !Le(i)
|
|
3862
3865
|
}), a.getURL();
|
|
3863
3866
|
}
|
|
3864
3867
|
/** Downloads and extracts a tar archive if it wasn't downloaded yet. */
|
|
@@ -3869,37 +3872,37 @@ class Sr {
|
|
|
3869
3872
|
/** Removes a directory and aborts a downloading task when all callers
|
|
3870
3873
|
* are not interested in it. */
|
|
3871
3874
|
async releasePath(e, t, o) {
|
|
3872
|
-
const n = this.idToDownload.get(
|
|
3875
|
+
const n = this.idToDownload.get(F(e, t));
|
|
3873
3876
|
if (n != null)
|
|
3874
3877
|
if (this.cache.existsFile(n.path)) {
|
|
3875
3878
|
const r = this.cache.removeFile(n.path, o);
|
|
3876
3879
|
await Promise.all(
|
|
3877
3880
|
r.map(async (a) => {
|
|
3878
|
-
await
|
|
3881
|
+
await de(a.path), this.cache.removeCache(a), this.removeTask(
|
|
3879
3882
|
a,
|
|
3880
|
-
`the task ${
|
|
3883
|
+
`the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
|
|
3881
3884
|
);
|
|
3882
3885
|
})
|
|
3883
3886
|
);
|
|
3884
3887
|
} else
|
|
3885
3888
|
n.counter.dec(o) && this.removeTask(
|
|
3886
3889
|
n,
|
|
3887
|
-
`the task ${
|
|
3890
|
+
`the task ${b(n.info())} was removed from cache`
|
|
3888
3891
|
);
|
|
3889
3892
|
}
|
|
3890
3893
|
/** Removes all files from a hard drive. */
|
|
3891
3894
|
async releaseAll() {
|
|
3892
3895
|
this.downloadQueue.stop(), await Promise.all(
|
|
3893
3896
|
Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
|
|
3894
|
-
await
|
|
3897
|
+
await de(t.path), this.cache.removeCache(t), this.removeTask(
|
|
3895
3898
|
t,
|
|
3896
|
-
`the task ${
|
|
3899
|
+
`the task ${b(t.info())} was released when the driver was closed`
|
|
3897
3900
|
);
|
|
3898
3901
|
})
|
|
3899
3902
|
);
|
|
3900
3903
|
}
|
|
3901
3904
|
setNewTask(e, t, o, n) {
|
|
3902
|
-
const r = new
|
|
3905
|
+
const r = new Ln(
|
|
3903
3906
|
this.logger,
|
|
3904
3907
|
this.signer,
|
|
3905
3908
|
this.saveDir,
|
|
@@ -3908,19 +3911,19 @@ class Sr {
|
|
|
3908
3911
|
o,
|
|
3909
3912
|
this.clientDownload
|
|
3910
3913
|
);
|
|
3911
|
-
return r.attach(e, n), this.idToDownload.set(
|
|
3914
|
+
return r.attach(e, n), this.idToDownload.set(F(t.id, o), r), r;
|
|
3912
3915
|
}
|
|
3913
3916
|
removeTask(e, t) {
|
|
3914
|
-
e.abort(t), e.change.markChanged(), this.idToDownload.delete(
|
|
3917
|
+
e.abort(t), e.change.markChanged(), this.idToDownload.delete(F(e.rInfo.id, e.format));
|
|
3915
3918
|
}
|
|
3916
3919
|
getFilePath(e, t) {
|
|
3917
|
-
return
|
|
3920
|
+
return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
|
|
3918
3921
|
}
|
|
3919
3922
|
}
|
|
3920
|
-
class
|
|
3923
|
+
class Un {
|
|
3921
3924
|
constructor(e, t, o, n, r, a) {
|
|
3922
|
-
d(this, "change", new
|
|
3923
|
-
d(this, "counter", new
|
|
3925
|
+
d(this, "change", new $());
|
|
3926
|
+
d(this, "counter", new N());
|
|
3924
3927
|
d(this, "nMaxUploads");
|
|
3925
3928
|
d(this, "nPartsWithThisUploadSpeed", 0);
|
|
3926
3929
|
d(this, "nPartsToIncreaseUpload", 10);
|
|
@@ -3934,21 +3937,21 @@ class Pn {
|
|
|
3934
3937
|
* At this case, the task will show progress == 1.0. */
|
|
3935
3938
|
d(this, "alreadyExisted", !1);
|
|
3936
3939
|
this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
|
|
3937
|
-
const { uploadData: i, progress: c } =
|
|
3940
|
+
const { uploadData: i, progress: c } = Rn(a, r);
|
|
3938
3941
|
this.uploadData = i, this.progress = c;
|
|
3939
3942
|
}
|
|
3940
3943
|
getProgress(e, t) {
|
|
3941
3944
|
if (this.incCounter(e, t), this.failed)
|
|
3942
3945
|
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3943
|
-
return
|
|
3946
|
+
return In(this.progress);
|
|
3944
3947
|
}
|
|
3945
3948
|
shouldScheduleUpload() {
|
|
3946
|
-
return
|
|
3949
|
+
return Sn(this.progress);
|
|
3947
3950
|
}
|
|
3948
3951
|
/** Uploads a blob if it's not BlobIndex. */
|
|
3949
3952
|
async uploadBlobTask() {
|
|
3950
3953
|
try {
|
|
3951
|
-
await
|
|
3954
|
+
await Dn(
|
|
3952
3955
|
this.logger,
|
|
3953
3956
|
this.clientBlob,
|
|
3954
3957
|
this.res,
|
|
@@ -3962,30 +3965,30 @@ class Pn {
|
|
|
3962
3965
|
}
|
|
3963
3966
|
), this.change.markChanged();
|
|
3964
3967
|
} catch (e) {
|
|
3965
|
-
if (this.setRetriableError(e),
|
|
3968
|
+
if (this.setRetriableError(e), Ie(e)) {
|
|
3966
3969
|
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3967
3970
|
return;
|
|
3968
3971
|
}
|
|
3969
|
-
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(),
|
|
3972
|
+
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), tt(e)) {
|
|
3970
3973
|
this.setTerminalError(e);
|
|
3971
3974
|
return;
|
|
3972
3975
|
}
|
|
3973
|
-
throw
|
|
3976
|
+
throw Cn(e) && (this.nMaxUploads = En(this.logger, this.nMaxUploads, 1)), e;
|
|
3974
3977
|
}
|
|
3975
3978
|
}
|
|
3976
3979
|
async updateStatus() {
|
|
3977
3980
|
var e;
|
|
3978
3981
|
try {
|
|
3979
|
-
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n =
|
|
3982
|
+
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Bn(this.alreadyExisted, $n(t));
|
|
3980
3983
|
this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
|
|
3981
3984
|
} catch (t) {
|
|
3982
3985
|
if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
|
|
3983
3986
|
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
3984
3987
|
return;
|
|
3985
3988
|
}
|
|
3986
|
-
if (
|
|
3989
|
+
if (Ie(t)) {
|
|
3987
3990
|
this.logger.warn(
|
|
3988
|
-
`resource was not found while updating a status of BlobImport: ${t}, ${
|
|
3991
|
+
`resource was not found while updating a status of BlobImport: ${t}, ${b(this.res)}`
|
|
3989
3992
|
), this.change.markChanged(), this.setDone(!0);
|
|
3990
3993
|
return;
|
|
3991
3994
|
}
|
|
@@ -4001,7 +4004,7 @@ class Pn {
|
|
|
4001
4004
|
this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
|
|
4002
4005
|
}
|
|
4003
4006
|
setDoneIfOutputSet(e) {
|
|
4004
|
-
|
|
4007
|
+
vn(e) && (this.setDone(!0), this.alreadyExisted = !0);
|
|
4005
4008
|
}
|
|
4006
4009
|
setDone(e) {
|
|
4007
4010
|
this.progress.done = e, e && (this.progress.lastError = void 0);
|
|
@@ -4016,8 +4019,8 @@ class Pn {
|
|
|
4016
4019
|
return this.counter.isZero();
|
|
4017
4020
|
}
|
|
4018
4021
|
}
|
|
4019
|
-
async function
|
|
4020
|
-
|
|
4022
|
+
async function Dn(s, e, t, o, n, r) {
|
|
4023
|
+
Tt(he(t), "the upload operation can be done only for BlobUploads");
|
|
4021
4024
|
const a = 1e4;
|
|
4022
4025
|
if (n()) return;
|
|
4023
4026
|
const i = await e.initUpload(t, { timeout: a });
|
|
@@ -4031,78 +4034,78 @@ async function Un(s, e, t, o, n, r) {
|
|
|
4031
4034
|
BigInt(o.modificationTime),
|
|
4032
4035
|
l,
|
|
4033
4036
|
{ timeout: a }
|
|
4034
|
-
), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed =
|
|
4037
|
+
), s.info(`uploaded chunk ${l}/${i.overall} of resource: ${t.id}`), r.nPartsWithThisUploadSpeed++, r.nPartsWithThisUploadSpeed >= r.nPartsToIncreaseUpload && (r.nPartsWithThisUploadSpeed = 0, r.currentSpeed = _n(s, r.currentSpeed, r.maxSpeed), p.setConcurrency(r.currentSpeed)));
|
|
4035
4038
|
};
|
|
4036
|
-
await
|
|
4039
|
+
await we(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
|
|
4037
4040
|
}
|
|
4038
|
-
function
|
|
4041
|
+
function Rn(s, e) {
|
|
4039
4042
|
let t, o;
|
|
4040
|
-
return
|
|
4043
|
+
return he(s) && (o = J.parse(s.data), t = Nn(e, o.localPath, o.pathSignature)), {
|
|
4041
4044
|
uploadData: o,
|
|
4042
4045
|
progress: {
|
|
4043
4046
|
done: !1,
|
|
4044
4047
|
status: void 0,
|
|
4045
|
-
isUpload:
|
|
4048
|
+
isUpload: he(s),
|
|
4046
4049
|
isUploadSignMatch: t,
|
|
4047
4050
|
lastError: void 0
|
|
4048
4051
|
}
|
|
4049
4052
|
};
|
|
4050
4053
|
}
|
|
4051
|
-
function
|
|
4054
|
+
function Sn(s) {
|
|
4052
4055
|
return s.isUpload && (s.isUploadSignMatch ?? !1);
|
|
4053
4056
|
}
|
|
4054
|
-
function
|
|
4057
|
+
function In(s) {
|
|
4055
4058
|
return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
|
|
4056
4059
|
}
|
|
4057
|
-
function
|
|
4060
|
+
function vn(s) {
|
|
4058
4061
|
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
4059
4062
|
}
|
|
4060
|
-
function
|
|
4063
|
+
function he(s) {
|
|
4061
4064
|
return s.type.name.startsWith("BlobUpload");
|
|
4062
4065
|
}
|
|
4063
|
-
function
|
|
4066
|
+
function Nn(s, e, t) {
|
|
4064
4067
|
try {
|
|
4065
4068
|
return s.verify(e, t), !0;
|
|
4066
4069
|
} catch {
|
|
4067
4070
|
return !1;
|
|
4068
4071
|
}
|
|
4069
4072
|
}
|
|
4070
|
-
function
|
|
4073
|
+
function $n(s) {
|
|
4071
4074
|
return {
|
|
4072
4075
|
progress: s.progress ?? 0,
|
|
4073
4076
|
bytesProcessed: Number(s.bytesProcessed),
|
|
4074
4077
|
bytesTotal: Number(s.bytesTotal)
|
|
4075
4078
|
};
|
|
4076
4079
|
}
|
|
4077
|
-
function
|
|
4080
|
+
function Bn(s, e) {
|
|
4078
4081
|
return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
|
|
4079
4082
|
progress: 1,
|
|
4080
4083
|
bytesProcessed: Number(e.bytesTotal),
|
|
4081
4084
|
bytesTotal: Number(e.bytesTotal)
|
|
4082
4085
|
} : e;
|
|
4083
4086
|
}
|
|
4084
|
-
function
|
|
4087
|
+
function Ie(s) {
|
|
4085
4088
|
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
4086
4089
|
}
|
|
4087
|
-
function
|
|
4088
|
-
return s instanceof
|
|
4090
|
+
function tt(s) {
|
|
4091
|
+
return s instanceof Ae || s instanceof Me || s instanceof je;
|
|
4089
4092
|
}
|
|
4090
|
-
function
|
|
4093
|
+
function Cn(s) {
|
|
4091
4094
|
return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
|
|
4092
4095
|
}
|
|
4093
|
-
function
|
|
4096
|
+
function _n(s, e, t) {
|
|
4094
4097
|
const o = Math.min(e + 2, t);
|
|
4095
4098
|
return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
|
|
4096
4099
|
}
|
|
4097
|
-
function
|
|
4100
|
+
function En(s, e, t) {
|
|
4098
4101
|
const o = Math.max(Math.round(e / 2), t);
|
|
4099
4102
|
return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
|
|
4100
4103
|
}
|
|
4101
|
-
function
|
|
4102
|
-
const t =
|
|
4103
|
-
return t.resourceType.name.startsWith("BlobUpload") ?
|
|
4104
|
+
function On(s, e) {
|
|
4105
|
+
const t = O(s) ? e.accessor(s).node() : Fe(s) ? s.node() : s;
|
|
4106
|
+
return t.resourceType.name.startsWith("BlobUpload") ? A(t, sn) : A(t, an);
|
|
4104
4107
|
}
|
|
4105
|
-
class
|
|
4108
|
+
class vr {
|
|
4106
4109
|
constructor(e, t, o, n, r = {
|
|
4107
4110
|
nConcurrentPartUploads: 10,
|
|
4108
4111
|
nConcurrentGetProgresses: 10,
|
|
@@ -4118,14 +4121,14 @@ class Ir {
|
|
|
4118
4121
|
d(this, "keepRunning", !1);
|
|
4119
4122
|
/** Actual state of main loop. */
|
|
4120
4123
|
d(this, "currentLoop");
|
|
4121
|
-
this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new
|
|
4124
|
+
this.logger = e, this.signer = t, this.clientBlob = o, this.clientProgress = n, this.opts = r, this.uploadQueue = new G(this.logger, 1, {
|
|
4122
4125
|
type: "exponentialWithMaxDelayBackoff",
|
|
4123
4126
|
initialDelay: 20,
|
|
4124
4127
|
maxDelay: 15e3,
|
|
4125
4128
|
// 15 seconds
|
|
4126
4129
|
backoffMultiplier: 1.5,
|
|
4127
4130
|
jitter: 0.5
|
|
4128
|
-
}), this.hooks = new
|
|
4131
|
+
}), this.hooks = new Oe(
|
|
4129
4132
|
() => this.startUpdating(),
|
|
4130
4133
|
() => this.stopUpdating(),
|
|
4131
4134
|
{ stopDebounce: r.stopPollingDelay },
|
|
@@ -4133,16 +4136,16 @@ class Ir {
|
|
|
4133
4136
|
);
|
|
4134
4137
|
}
|
|
4135
4138
|
getProgressId(e, t) {
|
|
4136
|
-
if (t == null) return
|
|
4137
|
-
const o =
|
|
4139
|
+
if (t == null) return y.make((a) => this.getProgressId(e, a));
|
|
4140
|
+
const o = O(e) ? On(e, t) : e, n = D();
|
|
4138
4141
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
|
|
4139
4142
|
}
|
|
4140
4143
|
getProgressIdNoCtx(e, t, o) {
|
|
4141
|
-
|
|
4144
|
+
Wn("getProgressId", t.type);
|
|
4142
4145
|
const n = this.idToProgress.get(t.id);
|
|
4143
4146
|
if (n != null)
|
|
4144
4147
|
return n.setDoneIfOutputSet(t), n.getProgress(e, o);
|
|
4145
|
-
const r = new
|
|
4148
|
+
const r = new Un(
|
|
4146
4149
|
this.logger,
|
|
4147
4150
|
this.clientBlob,
|
|
4148
4151
|
this.clientProgress,
|
|
@@ -4152,7 +4155,7 @@ class Ir {
|
|
|
4152
4155
|
);
|
|
4153
4156
|
return this.idToProgress.set(t.id, r), r.shouldScheduleUpload() && this.uploadQueue.push({
|
|
4154
4157
|
fn: () => r.uploadBlobTask(),
|
|
4155
|
-
recoverableErrorPredicate: (a) => !
|
|
4158
|
+
recoverableErrorPredicate: (a) => !tt(a)
|
|
4156
4159
|
}), r.setDoneIfOutputSet(t), r.getProgress(e, o);
|
|
4157
4160
|
}
|
|
4158
4161
|
/** Decrement counters for the file and remove an uploading if counter == 0. */
|
|
@@ -4181,7 +4184,7 @@ class Ir {
|
|
|
4181
4184
|
const e = this.scheduledOnNextState;
|
|
4182
4185
|
this.scheduledOnNextState = [];
|
|
4183
4186
|
try {
|
|
4184
|
-
await
|
|
4187
|
+
await we(
|
|
4185
4188
|
this.opts.nConcurrentGetProgresses,
|
|
4186
4189
|
this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
|
|
4187
4190
|
), e.forEach((t) => t.resolve());
|
|
@@ -4189,25 +4192,25 @@ class Ir {
|
|
|
4189
4192
|
console.error(t), e.forEach((o) => o.reject(t));
|
|
4190
4193
|
}
|
|
4191
4194
|
if (!this.keepRunning) break;
|
|
4192
|
-
await
|
|
4195
|
+
await ze.wait(this.opts.pollingInterval);
|
|
4193
4196
|
}
|
|
4194
4197
|
this.currentLoop = void 0;
|
|
4195
4198
|
}
|
|
4196
4199
|
getAllNotDoneProgresses() {
|
|
4197
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !
|
|
4200
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !Fn(t.progress)).map(([e, t]) => t);
|
|
4198
4201
|
}
|
|
4199
4202
|
}
|
|
4200
|
-
function
|
|
4203
|
+
function Fn(s) {
|
|
4201
4204
|
var e;
|
|
4202
4205
|
return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
|
|
4203
4206
|
}
|
|
4204
|
-
function
|
|
4207
|
+
function Wn(s, e) {
|
|
4205
4208
|
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
4206
|
-
throw new
|
|
4209
|
+
throw new Ue(
|
|
4207
4210
|
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
4208
4211
|
);
|
|
4209
4212
|
}
|
|
4210
|
-
class
|
|
4213
|
+
class Nr {
|
|
4211
4214
|
constructor(e, t, o = {
|
|
4212
4215
|
nConcurrentGetLogs: 10,
|
|
4213
4216
|
pollingInterval: 1e3,
|
|
@@ -4224,7 +4227,7 @@ class vr {
|
|
|
4224
4227
|
d(this, "keepRunning", !1);
|
|
4225
4228
|
/** Actual state of main loop. */
|
|
4226
4229
|
d(this, "currentLoop");
|
|
4227
|
-
this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new
|
|
4230
|
+
this.logger = e, this.clientLogs = t, this.opts = o, this.hooks = new Oe(
|
|
4228
4231
|
() => this.startUpdating(),
|
|
4229
4232
|
() => this.stopUpdating(),
|
|
4230
4233
|
{ stopDebounce: o.stopPollingDelay },
|
|
@@ -4232,8 +4235,8 @@ class vr {
|
|
|
4232
4235
|
);
|
|
4233
4236
|
}
|
|
4234
4237
|
getLastLogs(e, t, o) {
|
|
4235
|
-
if (o == null) return
|
|
4236
|
-
const n =
|
|
4238
|
+
if (o == null) return y.make((i) => this.getLastLogs(e, t, i));
|
|
4239
|
+
const n = S(e, o), r = D();
|
|
4237
4240
|
o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseLastLogs(n.id, r));
|
|
4238
4241
|
const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
|
|
4239
4242
|
return o.markUnstable(
|
|
@@ -4241,10 +4244,10 @@ class vr {
|
|
|
4241
4244
|
), a;
|
|
4242
4245
|
}
|
|
4243
4246
|
getLastLogsNoCtx(e, t, o, n) {
|
|
4244
|
-
|
|
4247
|
+
ie("getLastLogs", t.type);
|
|
4245
4248
|
let r = this.idToLastLines.get(t.id);
|
|
4246
4249
|
if (r == null) {
|
|
4247
|
-
const i = new
|
|
4250
|
+
const i = new ve(this.logger, this.clientLogs, t, o);
|
|
4248
4251
|
this.idToLastLines.set(t.id, i), r = i;
|
|
4249
4252
|
}
|
|
4250
4253
|
r.attach(e, n);
|
|
@@ -4254,8 +4257,8 @@ class vr {
|
|
|
4254
4257
|
}
|
|
4255
4258
|
getProgressLog(e, t, o) {
|
|
4256
4259
|
if (o == null)
|
|
4257
|
-
return
|
|
4258
|
-
const n =
|
|
4260
|
+
return y.make((i) => this.getProgressLog(e, t, i));
|
|
4261
|
+
const n = S(e, o), r = D();
|
|
4259
4262
|
o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseProgressLog(n.id, r));
|
|
4260
4263
|
const a = this.getProgressLogNoCtx(o.watcher, n, t, r);
|
|
4261
4264
|
return o.markUnstable(
|
|
@@ -4263,10 +4266,10 @@ class vr {
|
|
|
4263
4266
|
), a;
|
|
4264
4267
|
}
|
|
4265
4268
|
getProgressLogNoCtx(e, t, o, n) {
|
|
4266
|
-
|
|
4269
|
+
ie("getProgressLog", t.type);
|
|
4267
4270
|
let r = this.idToProgressLog.get(t.id);
|
|
4268
4271
|
if (r == null) {
|
|
4269
|
-
const i = new
|
|
4272
|
+
const i = new ve(this.logger, this.clientLogs, t, 1, o);
|
|
4270
4273
|
this.idToProgressLog.set(t.id, i), r = i;
|
|
4271
4274
|
}
|
|
4272
4275
|
r.attach(e, n);
|
|
@@ -4275,18 +4278,18 @@ class vr {
|
|
|
4275
4278
|
return a.log;
|
|
4276
4279
|
}
|
|
4277
4280
|
getLogHandle(e, t) {
|
|
4278
|
-
if (t == null) return
|
|
4279
|
-
const o =
|
|
4280
|
-
return t.markUnstable(`live_log:${
|
|
4281
|
+
if (t == null) return y.make((r) => this.getLogHandle(e, r));
|
|
4282
|
+
const o = S(e, t), n = this.getLogHandleNoCtx(o);
|
|
4283
|
+
return t.markUnstable(`live_log:${ct(o.id)}`), n;
|
|
4281
4284
|
}
|
|
4282
4285
|
getLogHandleNoCtx(e) {
|
|
4283
|
-
return
|
|
4286
|
+
return ie("getLogHandle", e.type), Qe(!0, e);
|
|
4284
4287
|
}
|
|
4285
4288
|
async lastLines(e, t, o, n) {
|
|
4286
4289
|
return await this.tryWithNotFound(
|
|
4287
4290
|
e,
|
|
4288
4291
|
() => this.clientLogs.lastLines(
|
|
4289
|
-
|
|
4292
|
+
H(e),
|
|
4290
4293
|
t,
|
|
4291
4294
|
BigInt(o ?? 0),
|
|
4292
4295
|
n
|
|
@@ -4297,7 +4300,7 @@ class vr {
|
|
|
4297
4300
|
return await this.tryWithNotFound(
|
|
4298
4301
|
e,
|
|
4299
4302
|
() => this.clientLogs.readText(
|
|
4300
|
-
|
|
4303
|
+
H(e),
|
|
4301
4304
|
t,
|
|
4302
4305
|
BigInt(o ?? 0),
|
|
4303
4306
|
n
|
|
@@ -4305,7 +4308,7 @@ class vr {
|
|
|
4305
4308
|
);
|
|
4306
4309
|
}
|
|
4307
4310
|
async tryWithNotFound(e, t) {
|
|
4308
|
-
if (!
|
|
4311
|
+
if (!M(e))
|
|
4309
4312
|
throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
|
|
4310
4313
|
try {
|
|
4311
4314
|
const o = await t();
|
|
@@ -4349,7 +4352,7 @@ class vr {
|
|
|
4349
4352
|
this.scheduledOnNextState = [];
|
|
4350
4353
|
try {
|
|
4351
4354
|
const t = this.getAllLogs();
|
|
4352
|
-
await
|
|
4355
|
+
await we(
|
|
4353
4356
|
this.opts.nConcurrentGetLogs,
|
|
4354
4357
|
t.map((o) => async () => await o.update())
|
|
4355
4358
|
), e.forEach((o) => o.resolve());
|
|
@@ -4357,7 +4360,7 @@ class vr {
|
|
|
4357
4360
|
console.error(t), e.forEach((o) => o.reject(t));
|
|
4358
4361
|
}
|
|
4359
4362
|
if (!this.keepRunning) break;
|
|
4360
|
-
await
|
|
4363
|
+
await ze.wait(this.opts.pollingInterval);
|
|
4361
4364
|
}
|
|
4362
4365
|
this.currentLoop = void 0;
|
|
4363
4366
|
}
|
|
@@ -4365,12 +4368,12 @@ class vr {
|
|
|
4365
4368
|
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
|
|
4366
4369
|
}
|
|
4367
4370
|
}
|
|
4368
|
-
class
|
|
4371
|
+
class ve {
|
|
4369
4372
|
constructor(e, t, o, n, r) {
|
|
4370
4373
|
d(this, "logs");
|
|
4371
4374
|
d(this, "error");
|
|
4372
|
-
d(this, "change", new
|
|
4373
|
-
d(this, "counter", new
|
|
4375
|
+
d(this, "change", new $());
|
|
4376
|
+
d(this, "counter", new N());
|
|
4374
4377
|
this.logger = e, this.clientLogs = t, this.rInfo = o, this.lines = n, this.patternToSearch = r;
|
|
4375
4378
|
}
|
|
4376
4379
|
getLog() {
|
|
@@ -4401,29 +4404,29 @@ class Ie {
|
|
|
4401
4404
|
return;
|
|
4402
4405
|
}
|
|
4403
4406
|
throw this.logger.error(
|
|
4404
|
-
`Stream log lines for ${
|
|
4407
|
+
`Stream log lines for ${b(this.rInfo.id)} failed, reason: ${e}`
|
|
4405
4408
|
), e;
|
|
4406
4409
|
}
|
|
4407
4410
|
}
|
|
4408
4411
|
}
|
|
4409
|
-
function
|
|
4412
|
+
function ie(s, e) {
|
|
4410
4413
|
if (!e.name.startsWith("StreamWorkdir"))
|
|
4411
|
-
throw new
|
|
4414
|
+
throw new Ue(
|
|
4412
4415
|
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4413
4416
|
);
|
|
4414
4417
|
}
|
|
4415
|
-
class
|
|
4418
|
+
class $r {
|
|
4416
4419
|
constructor(e, t, o) {
|
|
4417
4420
|
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = o;
|
|
4418
4421
|
}
|
|
4419
4422
|
getLastLogs(e, t, o) {
|
|
4420
|
-
if (o === void 0) return
|
|
4421
|
-
const n =
|
|
4423
|
+
if (o === void 0) return y.make((r) => this.getLastLogs(e, t, r));
|
|
4424
|
+
const n = z(o, e);
|
|
4422
4425
|
if (n === void 0) {
|
|
4423
4426
|
o.markUnstable("no stream in stream manager");
|
|
4424
4427
|
return;
|
|
4425
4428
|
}
|
|
4426
|
-
if (
|
|
4429
|
+
if (W(n)) return this.downloadDriver.getLastLogs(n, t, o);
|
|
4427
4430
|
try {
|
|
4428
4431
|
return this.logsStreamDriver.getLastLogs(n, t, o);
|
|
4429
4432
|
} catch (r) {
|
|
@@ -4436,13 +4439,13 @@ class Nr {
|
|
|
4436
4439
|
}
|
|
4437
4440
|
getProgressLog(e, t, o) {
|
|
4438
4441
|
if (o === void 0)
|
|
4439
|
-
return
|
|
4440
|
-
const n =
|
|
4442
|
+
return y.make((r) => this.getProgressLog(e, t, r));
|
|
4443
|
+
const n = z(o, e);
|
|
4441
4444
|
if (n === void 0) {
|
|
4442
4445
|
o.markUnstable("no stream in stream manager");
|
|
4443
4446
|
return;
|
|
4444
4447
|
}
|
|
4445
|
-
if (
|
|
4448
|
+
if (W(n)) return this.downloadDriver.getProgressLog(n, t, o);
|
|
4446
4449
|
try {
|
|
4447
4450
|
return this.logsStreamDriver.getProgressLog(n, t, o);
|
|
4448
4451
|
} catch (r) {
|
|
@@ -4455,13 +4458,13 @@ class Nr {
|
|
|
4455
4458
|
}
|
|
4456
4459
|
getProgressLogWithInfo(e, t, o) {
|
|
4457
4460
|
if (o === void 0)
|
|
4458
|
-
return
|
|
4459
|
-
const n =
|
|
4461
|
+
return y.make((r) => this.getProgressLogWithInfo(e, t, r));
|
|
4462
|
+
const n = z(o, e);
|
|
4460
4463
|
if (n === void 0) {
|
|
4461
4464
|
o.markUnstable("no stream in stream manager");
|
|
4462
4465
|
return;
|
|
4463
4466
|
}
|
|
4464
|
-
if (
|
|
4467
|
+
if (W(n))
|
|
4465
4468
|
return {
|
|
4466
4469
|
progressLine: this.downloadDriver.getProgressLog(n, t, o),
|
|
4467
4470
|
live: !1
|
|
@@ -4480,29 +4483,29 @@ class Nr {
|
|
|
4480
4483
|
}
|
|
4481
4484
|
}
|
|
4482
4485
|
getLogHandle(e, t) {
|
|
4483
|
-
if (t === void 0) return
|
|
4484
|
-
const o =
|
|
4486
|
+
if (t === void 0) return y.make((n) => this.getLogHandle(e, n));
|
|
4487
|
+
const o = z(t, e);
|
|
4485
4488
|
if (o === void 0) {
|
|
4486
4489
|
t.markUnstable("no stream in stream manager");
|
|
4487
4490
|
return;
|
|
4488
4491
|
}
|
|
4489
|
-
return
|
|
4492
|
+
return W(o) ? this.downloadDriver.getLogHandle(o, t) : this.logsStreamDriver.getLogHandle(o, t);
|
|
4490
4493
|
}
|
|
4491
4494
|
async lastLines(e, t, o, n) {
|
|
4492
|
-
return
|
|
4495
|
+
return M(e) ? await this.logsStreamDriver.lastLines(e, t, o, n) : await this.downloadDriver.lastLines(e, t, o, n);
|
|
4493
4496
|
}
|
|
4494
4497
|
async readText(e, t, o, n) {
|
|
4495
|
-
return
|
|
4498
|
+
return M(e) ? await this.logsStreamDriver.readText(e, t, o, n) : await this.downloadDriver.readText(e, t, o, n);
|
|
4496
4499
|
}
|
|
4497
4500
|
}
|
|
4498
|
-
function
|
|
4501
|
+
function W(s) {
|
|
4499
4502
|
return !s.type.name.startsWith("StreamWorkdir");
|
|
4500
4503
|
}
|
|
4501
|
-
function
|
|
4504
|
+
function z(s, e) {
|
|
4502
4505
|
var t;
|
|
4503
4506
|
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4504
4507
|
}
|
|
4505
|
-
class
|
|
4508
|
+
class Br {
|
|
4506
4509
|
constructor(e, t, o, n = {
|
|
4507
4510
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
4508
4511
|
withGunzip: !0,
|
|
@@ -4514,11 +4517,11 @@ class $r {
|
|
|
4514
4517
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4515
4518
|
* file that should be kept. */
|
|
4516
4519
|
d(this, "cache");
|
|
4517
|
-
this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new
|
|
4520
|
+
this.logger = e, this.saveDir = o, this.opts = n, this.downloadQueue = new G(this.logger, this.opts.nConcurrentDownloads), this.cache = new Pe(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Ge(t);
|
|
4518
4521
|
}
|
|
4519
4522
|
getPath(e, t) {
|
|
4520
|
-
if (t === void 0) return
|
|
4521
|
-
const o =
|
|
4523
|
+
if (t === void 0) return y.make((r) => this.getPath(e, r));
|
|
4524
|
+
const o = D();
|
|
4522
4525
|
t.addOnDestroy(() => this.releasePath(e, o));
|
|
4523
4526
|
const n = this.getPathNoCtx(e, t.watcher, o);
|
|
4524
4527
|
return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
|
|
@@ -4549,45 +4552,45 @@ class $r {
|
|
|
4549
4552
|
const r = this.cache.removeFile(n.path, t);
|
|
4550
4553
|
await Promise.all(
|
|
4551
4554
|
r.map(async (a) => {
|
|
4552
|
-
await
|
|
4555
|
+
await ue(a.path), this.cache.removeCache(a), this.removeTask(
|
|
4553
4556
|
a,
|
|
4554
|
-
`the task ${
|
|
4557
|
+
`the task ${b(a.info())} was removedfrom cache along with ${b(r.map((i) => i.info()))}`
|
|
4555
4558
|
);
|
|
4556
4559
|
})
|
|
4557
4560
|
);
|
|
4558
4561
|
} else
|
|
4559
4562
|
n.counter.dec(t) && this.removeTask(
|
|
4560
4563
|
n,
|
|
4561
|
-
`the task ${
|
|
4564
|
+
`the task ${b(n.info())} was removed from cache`
|
|
4562
4565
|
);
|
|
4563
4566
|
}
|
|
4564
4567
|
/** Removes all files from a hard drive. */
|
|
4565
4568
|
async releaseAll() {
|
|
4566
4569
|
this.downloadQueue.stop(), await Promise.all(
|
|
4567
4570
|
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4568
|
-
await
|
|
4571
|
+
await ue(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4569
4572
|
t,
|
|
4570
|
-
`the task ${
|
|
4573
|
+
`the task ${b(t.info())} was released when the driver was closed`
|
|
4571
4574
|
);
|
|
4572
4575
|
})
|
|
4573
4576
|
);
|
|
4574
4577
|
}
|
|
4575
4578
|
setNewTask(e, t, o) {
|
|
4576
|
-
const n = new
|
|
4579
|
+
const n = new zn(this.logger, this.getFilePath(t), t);
|
|
4577
4580
|
return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
|
|
4578
4581
|
}
|
|
4579
4582
|
removeTask(e, t) {
|
|
4580
4583
|
e.abort(t), e.change.markChanged(), this.urlToDownload.delete(e.url.toString());
|
|
4581
4584
|
}
|
|
4582
4585
|
getFilePath(e) {
|
|
4583
|
-
const t =
|
|
4584
|
-
return
|
|
4586
|
+
const t = mt("sha256").update(e.toString()).digest("hex");
|
|
4587
|
+
return T.join(this.saveDir, t);
|
|
4585
4588
|
}
|
|
4586
4589
|
}
|
|
4587
|
-
class
|
|
4590
|
+
class zn {
|
|
4588
4591
|
constructor(e, t, o) {
|
|
4589
|
-
d(this, "counter", new
|
|
4590
|
-
d(this, "change", new
|
|
4592
|
+
d(this, "counter", new N());
|
|
4593
|
+
d(this, "change", new $());
|
|
4591
4594
|
d(this, "signalCtl", new AbortController());
|
|
4592
4595
|
d(this, "error");
|
|
4593
4596
|
d(this, "done", !1);
|
|
@@ -4611,30 +4614,30 @@ class Wn {
|
|
|
4611
4614
|
const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
|
|
4612
4615
|
this.setDone(o), this.change.markChanged();
|
|
4613
4616
|
} catch (o) {
|
|
4614
|
-
if (o instanceof
|
|
4615
|
-
this.setError(o), this.change.markChanged(), await
|
|
4617
|
+
if (o instanceof Ne || o instanceof q) {
|
|
4618
|
+
this.setError(o), this.change.markChanged(), await ue(this.path);
|
|
4616
4619
|
return;
|
|
4617
4620
|
}
|
|
4618
4621
|
throw o;
|
|
4619
4622
|
}
|
|
4620
4623
|
}
|
|
4621
4624
|
async downloadAndUntar(e, t, o) {
|
|
4622
|
-
if (await
|
|
4623
|
-
return await
|
|
4625
|
+
if (await ge(T.dirname(this.path)), await fe(this.path))
|
|
4626
|
+
return await ot(this.path);
|
|
4624
4627
|
const n = await e.download(this.url.toString(), {}, o);
|
|
4625
4628
|
let r = n.content;
|
|
4626
4629
|
if (t) {
|
|
4627
|
-
const a =
|
|
4630
|
+
const a = _e.toWeb(We.createGunzip());
|
|
4628
4631
|
r = r.pipeThrough(a, { signal: o });
|
|
4629
4632
|
}
|
|
4630
|
-
return await
|
|
4633
|
+
return await me(this.logger, this.path, async (a) => {
|
|
4631
4634
|
await m.mkdir(a);
|
|
4632
|
-
const i =
|
|
4635
|
+
const i = I.toWeb(ce.extract(a));
|
|
4633
4636
|
await r.pipeTo(i, { signal: o });
|
|
4634
4637
|
}), n.size;
|
|
4635
4638
|
}
|
|
4636
4639
|
getPath() {
|
|
4637
|
-
if (this.done) return { path:
|
|
4640
|
+
if (this.done) return { path: j(this.path) };
|
|
4638
4641
|
if (this.error) return { error: this.error };
|
|
4639
4642
|
}
|
|
4640
4643
|
setDone(e) {
|
|
@@ -4644,30 +4647,30 @@ class Wn {
|
|
|
4644
4647
|
this.error = String(e);
|
|
4645
4648
|
}
|
|
4646
4649
|
abort(e) {
|
|
4647
|
-
this.signalCtl.abort(new
|
|
4650
|
+
this.signalCtl.abort(new Ne(e));
|
|
4648
4651
|
}
|
|
4649
4652
|
}
|
|
4650
|
-
class
|
|
4653
|
+
class Ne extends Error {
|
|
4651
4654
|
}
|
|
4652
|
-
async function
|
|
4655
|
+
async function ot(s) {
|
|
4653
4656
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
4654
4657
|
return (await Promise.all(
|
|
4655
4658
|
e.map(async (o) => {
|
|
4656
|
-
const n =
|
|
4657
|
-
return o.isDirectory() ? await
|
|
4659
|
+
const n = T.join(s, o.name);
|
|
4660
|
+
return o.isDirectory() ? await ot(n) : (await m.stat(n)).size;
|
|
4658
4661
|
})
|
|
4659
4662
|
)).reduce((o, n) => o + n, 0);
|
|
4660
4663
|
}
|
|
4661
|
-
async function
|
|
4664
|
+
async function ue(s) {
|
|
4662
4665
|
await m.rm(s, { recursive: !0, force: !0 });
|
|
4663
4666
|
}
|
|
4664
|
-
function
|
|
4667
|
+
function ae(s, e) {
|
|
4665
4668
|
return `index://index/${encodeURIComponent(JSON.stringify({
|
|
4666
4669
|
storageId: s,
|
|
4667
4670
|
path: e
|
|
4668
4671
|
}))}`;
|
|
4669
4672
|
}
|
|
4670
|
-
function
|
|
4673
|
+
function xn(s, e, t, o) {
|
|
4671
4674
|
const n = {
|
|
4672
4675
|
localPath: s,
|
|
4673
4676
|
pathSignature: e.sign(s),
|
|
@@ -4676,32 +4679,32 @@ function zn(s, e, t, o) {
|
|
|
4676
4679
|
};
|
|
4677
4680
|
return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
|
|
4678
4681
|
}
|
|
4679
|
-
function
|
|
4682
|
+
function An(s) {
|
|
4680
4683
|
const e = new URL(s);
|
|
4681
|
-
return
|
|
4684
|
+
return J.parse(
|
|
4682
4685
|
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4683
4686
|
);
|
|
4684
4687
|
}
|
|
4685
|
-
function
|
|
4688
|
+
function Mn(s) {
|
|
4686
4689
|
const e = new URL(s);
|
|
4687
|
-
return
|
|
4690
|
+
return Je.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4688
4691
|
}
|
|
4689
|
-
function
|
|
4690
|
-
if (
|
|
4691
|
-
return
|
|
4692
|
-
if (
|
|
4693
|
-
return
|
|
4694
|
-
|
|
4692
|
+
function $e(s) {
|
|
4693
|
+
if (Vn(s))
|
|
4694
|
+
return Jn(s);
|
|
4695
|
+
if (Hn(s))
|
|
4696
|
+
return Gn(s);
|
|
4697
|
+
pt(s);
|
|
4695
4698
|
}
|
|
4696
|
-
const
|
|
4697
|
-
function
|
|
4698
|
-
return
|
|
4699
|
+
const nt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4700
|
+
function Hn(s) {
|
|
4701
|
+
return nt.test(s);
|
|
4699
4702
|
}
|
|
4700
|
-
function
|
|
4703
|
+
function jn(s, e) {
|
|
4701
4704
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4702
4705
|
}
|
|
4703
|
-
function
|
|
4704
|
-
const e = s.match(
|
|
4706
|
+
function Gn(s) {
|
|
4707
|
+
const e = s.match(nt);
|
|
4705
4708
|
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4706
4709
|
const { name: t, path: o } = e.groups;
|
|
4707
4710
|
return {
|
|
@@ -4710,30 +4713,30 @@ function jn(s) {
|
|
|
4710
4713
|
isRemote: !1
|
|
4711
4714
|
};
|
|
4712
4715
|
}
|
|
4713
|
-
const
|
|
4714
|
-
function
|
|
4715
|
-
return
|
|
4716
|
+
const rt = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4717
|
+
function Vn(s) {
|
|
4718
|
+
return rt.test(s);
|
|
4716
4719
|
}
|
|
4717
|
-
function
|
|
4720
|
+
function qn(s, e) {
|
|
4718
4721
|
return `remote://${s}/${BigInt(e)}`;
|
|
4719
4722
|
}
|
|
4720
|
-
function
|
|
4721
|
-
const e = s.match(
|
|
4723
|
+
function Jn(s) {
|
|
4724
|
+
const e = s.match(rt);
|
|
4722
4725
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4723
4726
|
const { name: t, resourceId: o } = e.groups;
|
|
4724
4727
|
return {
|
|
4725
|
-
id:
|
|
4726
|
-
type:
|
|
4728
|
+
id: pe(BigInt(o)),
|
|
4729
|
+
type: Zn(t),
|
|
4727
4730
|
name: t,
|
|
4728
4731
|
isRemote: !0
|
|
4729
4732
|
};
|
|
4730
4733
|
}
|
|
4731
|
-
function
|
|
4734
|
+
function Zn(s) {
|
|
4732
4735
|
return { name: `LS/${s}`, version: "1" };
|
|
4733
4736
|
}
|
|
4734
|
-
async function
|
|
4735
|
-
const s =
|
|
4736
|
-
if (
|
|
4737
|
+
async function Qn() {
|
|
4738
|
+
const s = wt.homedir();
|
|
4739
|
+
if (P.sep == "/")
|
|
4737
4740
|
return [
|
|
4738
4741
|
{
|
|
4739
4742
|
name: "local",
|
|
@@ -4742,9 +4745,9 @@ async function Zn() {
|
|
|
4742
4745
|
}
|
|
4743
4746
|
];
|
|
4744
4747
|
{
|
|
4745
|
-
const t =
|
|
4748
|
+
const t = P.parse(s).root.replaceAll(":\\", "");
|
|
4746
4749
|
try {
|
|
4747
|
-
return (await
|
|
4750
|
+
return (await Lt.promisify(Pt)("wmic logicaldisk get name")).stdout.split(`\r
|
|
4748
4751
|
`).filter((r) => r.includes(":")).map((r) => r.trim().replaceAll(":", "")).map((r) => {
|
|
4749
4752
|
const a = r == t;
|
|
4750
4753
|
return {
|
|
@@ -4764,7 +4767,7 @@ async function Zn() {
|
|
|
4764
4767
|
}
|
|
4765
4768
|
}
|
|
4766
4769
|
}
|
|
4767
|
-
class
|
|
4770
|
+
class st {
|
|
4768
4771
|
constructor(e, t, o, n, r, a, i) {
|
|
4769
4772
|
this.logger = e, this.lsClient = t, this.storageIdToResourceId = o, this.signer = n, this.virtualStoragesMap = r, this.localProjectionsMap = a, this.openFileDialogCallback = i;
|
|
4770
4773
|
}
|
|
@@ -4796,13 +4799,13 @@ class rt {
|
|
|
4796
4799
|
* @private
|
|
4797
4800
|
*/
|
|
4798
4801
|
async tryResolveLocalFileHandle(e) {
|
|
4799
|
-
if (
|
|
4800
|
-
const t =
|
|
4802
|
+
if (kt(e)) {
|
|
4803
|
+
const t = Mn(e), o = this.localProjectionsMap.get(t.storageId);
|
|
4801
4804
|
if (!o)
|
|
4802
4805
|
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4803
|
-
return
|
|
4806
|
+
return T.join(o.localPath, t.path);
|
|
4804
4807
|
} else {
|
|
4805
|
-
const t =
|
|
4808
|
+
const t = An(e);
|
|
4806
4809
|
this.signer.verify(
|
|
4807
4810
|
t.localPath,
|
|
4808
4811
|
t.pathSignature,
|
|
@@ -4815,17 +4818,17 @@ class rt {
|
|
|
4815
4818
|
}
|
|
4816
4819
|
}
|
|
4817
4820
|
async getLocalFileHandle(e) {
|
|
4818
|
-
|
|
4821
|
+
_(e);
|
|
4819
4822
|
for (const o of this.localProjectionsMap.values())
|
|
4820
4823
|
if (e.startsWith(o.localPath)) {
|
|
4821
|
-
const n = o.localPath === "" ? e :
|
|
4822
|
-
return
|
|
4824
|
+
const n = o.localPath === "" ? e : T.relative(o.localPath, e);
|
|
4825
|
+
return ae(
|
|
4823
4826
|
o.storageId,
|
|
4824
4827
|
n
|
|
4825
4828
|
);
|
|
4826
4829
|
}
|
|
4827
4830
|
const t = await m.stat(e, { bigint: !0 });
|
|
4828
|
-
return
|
|
4831
|
+
return xn(
|
|
4829
4832
|
e,
|
|
4830
4833
|
this.signer,
|
|
4831
4834
|
t.size,
|
|
@@ -4836,12 +4839,12 @@ class rt {
|
|
|
4836
4839
|
async getStorageList() {
|
|
4837
4840
|
const e = [...this.virtualStoragesMap.values()].map((n) => ({
|
|
4838
4841
|
name: n.name,
|
|
4839
|
-
handle:
|
|
4842
|
+
handle: jn(n.name, n.root),
|
|
4840
4843
|
initialFullPath: n.initialPath
|
|
4841
4844
|
})), o = Object.entries(this.storageIdToResourceId).map(
|
|
4842
4845
|
([n, r]) => ({
|
|
4843
4846
|
name: n,
|
|
4844
|
-
handle:
|
|
4847
|
+
handle: qn(n, r),
|
|
4845
4848
|
initialFullPath: "",
|
|
4846
4849
|
// we don't have any additional information from where to start browsing remote storages
|
|
4847
4850
|
isInitialPathHome: !1
|
|
@@ -4850,21 +4853,21 @@ class rt {
|
|
|
4850
4853
|
return [...e, ...o];
|
|
4851
4854
|
}
|
|
4852
4855
|
async listFiles(e, t) {
|
|
4853
|
-
const o =
|
|
4856
|
+
const o = $e(e);
|
|
4854
4857
|
if (o.isRemote)
|
|
4855
4858
|
return {
|
|
4856
4859
|
entries: (await this.lsClient.list(o, t)).items.map((i) => ({
|
|
4857
4860
|
type: i.isDir ? "dir" : "file",
|
|
4858
4861
|
name: i.name,
|
|
4859
4862
|
fullPath: i.fullName,
|
|
4860
|
-
handle:
|
|
4863
|
+
handle: ae(o.name, i.fullName)
|
|
4861
4864
|
}))
|
|
4862
4865
|
};
|
|
4863
|
-
|
|
4864
|
-
const n =
|
|
4866
|
+
T.sep === "/" && t === "" && (t = "/"), o.rootPath === "" && _(t);
|
|
4867
|
+
const n = T.isAbsolute(t) ? t : T.join(o.rootPath, t), r = [];
|
|
4865
4868
|
for await (const a of await m.opendir(n)) {
|
|
4866
4869
|
if (!a.isFile() && !a.isDirectory()) continue;
|
|
4867
|
-
const i =
|
|
4870
|
+
const i = T.join(n, a.name);
|
|
4868
4871
|
r.push({
|
|
4869
4872
|
type: a.isFile() ? "file" : "dir",
|
|
4870
4873
|
name: a.name,
|
|
@@ -4875,7 +4878,7 @@ class rt {
|
|
|
4875
4878
|
return { entries: r };
|
|
4876
4879
|
}
|
|
4877
4880
|
async listRemoteFilesWithAdditionalInfo(e, t) {
|
|
4878
|
-
const o =
|
|
4881
|
+
const o = $e(e);
|
|
4879
4882
|
if (!o.isRemote)
|
|
4880
4883
|
throw new Error(`Storage ${o.name} is not remote`);
|
|
4881
4884
|
return {
|
|
@@ -4883,7 +4886,7 @@ class rt {
|
|
|
4883
4886
|
type: r.isDir ? "dir" : "file",
|
|
4884
4887
|
name: r.name,
|
|
4885
4888
|
fullPath: r.fullName,
|
|
4886
|
-
handle:
|
|
4889
|
+
handle: ae(o.name, r.fullName),
|
|
4887
4890
|
size: Number(r.size)
|
|
4888
4891
|
}))
|
|
4889
4892
|
};
|
|
@@ -4894,19 +4897,19 @@ class rt {
|
|
|
4894
4897
|
);
|
|
4895
4898
|
}
|
|
4896
4899
|
static async init(e, t, o, n, r, a) {
|
|
4897
|
-
const i =
|
|
4898
|
-
a || (a = await
|
|
4899
|
-
for (const p of a)
|
|
4900
|
-
for (const p of n) p.localPath !== "" &&
|
|
4900
|
+
const i = Yo(t, e);
|
|
4901
|
+
a || (a = await Qn());
|
|
4902
|
+
for (const p of a) _(p.root);
|
|
4903
|
+
for (const p of n) p.localPath !== "" && _(p.localPath);
|
|
4901
4904
|
const c = new Map(a.map((p) => [p.name, p])), l = new Map(n.map((p) => [p.storageId, p]));
|
|
4902
4905
|
if ((/* @__PURE__ */ new Set([...c.keys(), ...l.keys()])).size !== c.size + l.size)
|
|
4903
4906
|
throw new Error(
|
|
4904
4907
|
"Intersection between local projection storage ids and virtual storages names detected."
|
|
4905
4908
|
);
|
|
4906
|
-
return new
|
|
4909
|
+
return new st(
|
|
4907
4910
|
e,
|
|
4908
4911
|
i,
|
|
4909
|
-
await
|
|
4912
|
+
await Xn(t),
|
|
4910
4913
|
o,
|
|
4911
4914
|
c,
|
|
4912
4915
|
l,
|
|
@@ -4914,62 +4917,64 @@ class rt {
|
|
|
4914
4917
|
);
|
|
4915
4918
|
}
|
|
4916
4919
|
}
|
|
4917
|
-
async function
|
|
4920
|
+
async function Xn(s) {
|
|
4918
4921
|
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4919
4922
|
const t = await e.getResourceByName("LSProvider"), o = await e.getResourceData(t, !0);
|
|
4920
|
-
return
|
|
4923
|
+
return Kn(o);
|
|
4921
4924
|
});
|
|
4922
4925
|
}
|
|
4923
|
-
function
|
|
4926
|
+
function Kn(s) {
|
|
4924
4927
|
return Object.fromEntries(
|
|
4925
|
-
s.fields.filter((e) => e.type == "Dynamic" &&
|
|
4928
|
+
s.fields.filter((e) => e.type == "Dynamic" && dt(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4926
4929
|
);
|
|
4927
4930
|
}
|
|
4928
4931
|
export {
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4932
|
+
Po as ClientDownload,
|
|
4933
|
+
Ko as ClientLogs,
|
|
4934
|
+
Wo as ClientLs,
|
|
4935
|
+
po as ClientProgress,
|
|
4936
|
+
qt as ClientUpload,
|
|
4937
|
+
Qn as DefaultVirtualLocalStorages,
|
|
4938
|
+
Ir as DownloadBlobToURLDriver,
|
|
4939
|
+
Rr as DownloadDriver,
|
|
4940
|
+
Br as DownloadUrlDriver,
|
|
4941
|
+
mn as DownloadableBlobSnapshot,
|
|
4942
|
+
Dr as ImportFileHandleData,
|
|
4943
|
+
Je as ImportFileHandleIndexData,
|
|
4944
|
+
J as ImportFileHandleUploadData,
|
|
4945
|
+
an as IndexResourceSnapshot,
|
|
4946
|
+
$r as LogsDriver,
|
|
4947
|
+
Nr as LogsStreamDriver,
|
|
4948
|
+
st as LsDriver,
|
|
4949
|
+
Ae as MTimeError,
|
|
4950
|
+
He as NetworkError,
|
|
4951
|
+
je as NoFileForUploading,
|
|
4952
|
+
nn as OnDemandBlobResourceSnapshot,
|
|
4953
|
+
Me as UnexpectedEOF,
|
|
4954
|
+
ke as UnknownStorageError,
|
|
4955
|
+
un as Updater,
|
|
4956
|
+
vr as UploadDriver,
|
|
4957
|
+
sn as UploadResourceSnapshot,
|
|
4958
|
+
Un as UploadTask,
|
|
4959
|
+
Te as WrongLocalFileUrl,
|
|
4960
|
+
Ue as WrongResourceTypeError,
|
|
4961
|
+
kr as createDownloadClient,
|
|
4962
|
+
Lr as createLogsClient,
|
|
4963
|
+
Yo as createLsFilesClient,
|
|
4964
|
+
Ur as createUploadBlobClient,
|
|
4965
|
+
Pr as createUploadProgressClient,
|
|
4966
|
+
Do as getFullPath,
|
|
4967
|
+
rn as getSize,
|
|
4968
|
+
Sn as isMyUpload,
|
|
4969
|
+
Ie as isResourceWasDeletedError,
|
|
4970
|
+
Nn as isSignMatch,
|
|
4971
|
+
he as isUpload,
|
|
4972
|
+
On as makeBlobImportSnapshot,
|
|
4973
|
+
wn as makeDownloadableBlobSnapshot,
|
|
4974
|
+
Io as newLocalStorageIdsToRoot,
|
|
4975
|
+
tt as nonRecoverableError,
|
|
4976
|
+
Uo as parseLocalUrl,
|
|
4977
|
+
Dn as uploadBlob,
|
|
4978
|
+
_ as validateAbsolute
|
|
4974
4979
|
};
|
|
4975
4980
|
//# sourceMappingURL=index.mjs.map
|