@milaboratories/pl-drivers 1.5.3 → 1.5.5
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.map +1 -1
- package/dist/drivers/download_blob_task.d.ts +9 -0
- package/dist/drivers/download_blob_task.d.ts.map +1 -1
- package/dist/drivers/download_url.d.ts +7 -0
- package/dist/drivers/download_url.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -220
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/drivers/download_blob.test.ts +52 -4
- package/src/drivers/download_blob.ts +7 -4
- package/src/drivers/download_blob_task.ts +31 -12
- package/src/drivers/download_url.ts +24 -5
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
var Ze = Object.defineProperty;
|
|
2
2
|
var Qe = (s, e, t) => e in s ? Ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var d = (s, e, t) => Qe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { addRTypeToMetadata as T, bigintToResourceId as
|
|
4
|
+
import { addRTypeToMetadata as T, bigintToResourceId as te, stringifyWithResourceId as L, resourceIdToString as Xe, isNotNullResourceId as Ye } from "@milaboratories/pl-client";
|
|
5
5
|
import * as m from "node:fs/promises";
|
|
6
6
|
import { request as be } from "undici";
|
|
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
|
|
7
|
+
import { ServiceType as B, stackIntercept as y } from "@protobuf-ts/runtime-rpc";
|
|
8
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as I, typeofJsonValue as ke } from "@protobuf-ts/runtime";
|
|
9
|
+
import { notEmpty as re, CallersCounter as v, ensureDirExists as Te, fileExists as Le, createPathAtomically as Pe, mapGet as ue, mapEntries as Ke, TaskProcessor as ne, asyncPool as oe, assertNever as et } from "@milaboratories/ts-helpers";
|
|
10
|
+
import * as se from "node:fs";
|
|
11
11
|
import tt from "node:fs";
|
|
12
12
|
import * as w from "node:path";
|
|
13
|
-
import
|
|
14
|
-
import { Readable as
|
|
13
|
+
import X from "node:path";
|
|
14
|
+
import { Readable as ie, Writable as ae, Transform as rt } from "node:stream";
|
|
15
15
|
import { text as nt, buffer as Ie } from "node:stream/consumers";
|
|
16
|
-
import { ChangeSource as
|
|
17
|
-
import { rsSchema as
|
|
16
|
+
import { ChangeSource as $, Computable as b, PollingComputableHooks as Re } from "@milaboratories/computable";
|
|
17
|
+
import { rsSchema as le, treeEntryToResourceInfo as R, isPlTreeEntry as ce, makeResourceSnapshot as Y, isPlTreeEntryAccessor as ot } from "@milaboratories/pl-tree";
|
|
18
18
|
import st from "denque";
|
|
19
|
-
import { randomUUID as
|
|
20
|
-
import * as
|
|
19
|
+
import { randomUUID as P, createHash as it } from "node:crypto";
|
|
20
|
+
import * as pe from "node:os";
|
|
21
21
|
import at from "node:os";
|
|
22
22
|
import * as lt from "node:readline/promises";
|
|
23
23
|
import { z as k } from "zod";
|
|
@@ -163,7 +163,7 @@ class bt extends g {
|
|
|
163
163
|
case /* repeated uint64 uploaded_parts */
|
|
164
164
|
2:
|
|
165
165
|
if (c === h.LengthDelimited)
|
|
166
|
-
for (let
|
|
166
|
+
for (let E = e.int32() + e.pos; e.pos < E; )
|
|
167
167
|
o.uploadedParts.push(e.uint64().toBigInt());
|
|
168
168
|
else o.uploadedParts.push(e.uint64().toBigInt());
|
|
169
169
|
break;
|
|
@@ -495,7 +495,7 @@ class Dt extends g {
|
|
|
495
495
|
), t;
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
const
|
|
498
|
+
const W = new Dt();
|
|
499
499
|
class Bt extends g {
|
|
500
500
|
constructor() {
|
|
501
501
|
super("MiLaboratories.Controller.Shared.uploadapi.GetPartURL.Response", [
|
|
@@ -518,7 +518,7 @@ class Bt extends g {
|
|
|
518
518
|
name: "headers",
|
|
519
519
|
kind: "message",
|
|
520
520
|
repeat: 1,
|
|
521
|
-
T: () =>
|
|
521
|
+
T: () => W
|
|
522
522
|
},
|
|
523
523
|
{
|
|
524
524
|
no: 4,
|
|
@@ -562,7 +562,7 @@ class Bt extends g {
|
|
|
562
562
|
case /* repeated MiLaboratories.Controller.Shared.uploadapi.GetPartURL.HTTPHeader headers */
|
|
563
563
|
3:
|
|
564
564
|
o.headers.push(
|
|
565
|
-
|
|
565
|
+
W.internalBinaryRead(
|
|
566
566
|
e,
|
|
567
567
|
e.uint32(),
|
|
568
568
|
r
|
|
@@ -598,7 +598,7 @@ class Bt extends g {
|
|
|
598
598
|
internalBinaryWrite(e, t, r) {
|
|
599
599
|
e.uploadUrl !== "" && t.tag(1, h.LengthDelimited).string(e.uploadUrl), e.method !== "" && t.tag(2, h.LengthDelimited).string(e.method);
|
|
600
600
|
for (let o = 0; o < e.headers.length; o++)
|
|
601
|
-
|
|
601
|
+
W.internalBinaryWrite(
|
|
602
602
|
e.headers[o],
|
|
603
603
|
t.tag(3, h.LengthDelimited).fork(),
|
|
604
604
|
r
|
|
@@ -709,7 +709,7 @@ class Ot extends g {
|
|
|
709
709
|
), t;
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
|
-
const Ft = new Ot(),
|
|
712
|
+
const Ft = new Ot(), z = new B(
|
|
713
713
|
"MiLaboratories.Controller.Shared.Upload",
|
|
714
714
|
[
|
|
715
715
|
{
|
|
@@ -740,9 +740,9 @@ const Ft = new Ot(), W = new D(
|
|
|
740
740
|
);
|
|
741
741
|
class Et {
|
|
742
742
|
constructor(e) {
|
|
743
|
-
d(this, "typeName",
|
|
744
|
-
d(this, "methods",
|
|
745
|
-
d(this, "options",
|
|
743
|
+
d(this, "typeName", z.typeName);
|
|
744
|
+
d(this, "methods", z.methods);
|
|
745
|
+
d(this, "options", z.options);
|
|
746
746
|
this._transport = e;
|
|
747
747
|
}
|
|
748
748
|
/**
|
|
@@ -810,7 +810,7 @@ class Wt extends Error {
|
|
|
810
810
|
}
|
|
811
811
|
class Be extends Error {
|
|
812
812
|
}
|
|
813
|
-
class
|
|
813
|
+
class zt {
|
|
814
814
|
constructor(e, t, r, n) {
|
|
815
815
|
d(this, "grpcClient");
|
|
816
816
|
this.grpcTransport = e, this.httpClient = t, this.logger = n, this.grpcClient = new Et(this.grpcTransport);
|
|
@@ -831,19 +831,19 @@ class At {
|
|
|
831
831
|
0n,
|
|
832
832
|
// we update progress as a separate call later.
|
|
833
833
|
l
|
|
834
|
-
), c = await
|
|
834
|
+
), c = await At(r, i.chunkStart, i.chunkEnd);
|
|
835
835
|
await Mt(r, n);
|
|
836
836
|
const {
|
|
837
837
|
body: a,
|
|
838
838
|
statusCode: p,
|
|
839
|
-
headers:
|
|
839
|
+
headers: E
|
|
840
840
|
} = await be(i.uploadUrl, {
|
|
841
841
|
dispatcher: this.httpClient,
|
|
842
842
|
body: c,
|
|
843
843
|
headers: Ue(i.headers),
|
|
844
844
|
method: i.method.toUpperCase()
|
|
845
845
|
}), Je = await a.text();
|
|
846
|
-
Ht(p, Je,
|
|
846
|
+
Ht(p, Je, E, i), await this.grpcUpdateProgress({ id: e, type: t }, i.chunkEnd - i.chunkStart, l);
|
|
847
847
|
}
|
|
848
848
|
async finalize(e, t) {
|
|
849
849
|
return await this.grpcFinalize(e, t);
|
|
@@ -878,11 +878,11 @@ class At {
|
|
|
878
878
|
return await this.grpcClient.finalize({ resourceId: e }, T(t, r)).response;
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
|
-
async function
|
|
881
|
+
async function At(s, e, t) {
|
|
882
882
|
let r;
|
|
883
883
|
try {
|
|
884
884
|
r = await m.open(s);
|
|
885
|
-
const n = Number(t - e), o = Number(e), l = Buffer.alloc(n), i = await
|
|
885
|
+
const n = Number(t - e), o = Number(e), l = Buffer.alloc(n), i = await xt(r, l, n, o);
|
|
886
886
|
return l.subarray(0, i);
|
|
887
887
|
} catch (n) {
|
|
888
888
|
throw n.code == "ENOENT" ? new Be(`there is no file ${s} for uploading`) : n;
|
|
@@ -890,7 +890,7 @@ async function xt(s, e, t) {
|
|
|
890
890
|
r == null || r.close();
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
-
async function
|
|
893
|
+
async function xt(s, e, t, r) {
|
|
894
894
|
let n = 0;
|
|
895
895
|
for (; n < t; ) {
|
|
896
896
|
const { bytesRead: o } = await s.read(
|
|
@@ -940,7 +940,7 @@ class jt extends g {
|
|
|
940
940
|
* Encode `Duration` to JSON string like "3.000001s".
|
|
941
941
|
*/
|
|
942
942
|
internalJsonWrite(e, t) {
|
|
943
|
-
let r =
|
|
943
|
+
let r = I.from(e.seconds).toNumber();
|
|
944
944
|
if (r > 315576e6 || r < -315576e6)
|
|
945
945
|
throw new Error("Duration value out of range.");
|
|
946
946
|
let n = e.seconds.toString();
|
|
@@ -964,7 +964,7 @@ class jt extends g {
|
|
|
964
964
|
"Unable to parse Duration from JSON string. Invalid format."
|
|
965
965
|
);
|
|
966
966
|
r || (r = this.create());
|
|
967
|
-
let [, o, l, i] = n, c =
|
|
967
|
+
let [, o, l, i] = n, c = I.from(o + l);
|
|
968
968
|
if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
|
|
969
969
|
throw new Error(
|
|
970
970
|
"Unable to parse Duration from JSON string. Value out of range."
|
|
@@ -1020,7 +1020,7 @@ class jt extends g {
|
|
|
1020
1020
|
), t;
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
|
-
const
|
|
1023
|
+
const _ = new jt();
|
|
1024
1024
|
class Gt extends g {
|
|
1025
1025
|
constructor() {
|
|
1026
1026
|
super("MiLaboratories.Controller.Shared.ProgressAPI", []);
|
|
@@ -1141,7 +1141,7 @@ class Vt extends g {
|
|
|
1141
1141
|
), t;
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
|
-
const
|
|
1144
|
+
const S = new Vt();
|
|
1145
1145
|
class qt extends g {
|
|
1146
1146
|
constructor() {
|
|
1147
1147
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
@@ -1225,7 +1225,7 @@ const Zt = new Jt();
|
|
|
1225
1225
|
class Qt extends g {
|
|
1226
1226
|
constructor() {
|
|
1227
1227
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1228
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1228
|
+
{ no: 1, name: "report", kind: "message", T: () => S }
|
|
1229
1229
|
]);
|
|
1230
1230
|
}
|
|
1231
1231
|
create(e) {
|
|
@@ -1243,7 +1243,7 @@ class Qt extends g {
|
|
|
1243
1243
|
switch (i) {
|
|
1244
1244
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1245
1245
|
1:
|
|
1246
|
-
o.report =
|
|
1246
|
+
o.report = S.internalBinaryRead(
|
|
1247
1247
|
e,
|
|
1248
1248
|
e.uint32(),
|
|
1249
1249
|
r,
|
|
@@ -1269,7 +1269,7 @@ class Qt extends g {
|
|
|
1269
1269
|
return o;
|
|
1270
1270
|
}
|
|
1271
1271
|
internalBinaryWrite(e, t, r) {
|
|
1272
|
-
e.report &&
|
|
1272
|
+
e.report && S.internalBinaryWrite(
|
|
1273
1273
|
e.report,
|
|
1274
1274
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1275
1275
|
r
|
|
@@ -1317,7 +1317,7 @@ class Kt extends g {
|
|
|
1317
1317
|
L: 0
|
|
1318
1318
|
/*LongType.BIGINT*/
|
|
1319
1319
|
},
|
|
1320
|
-
{ no: 2, name: "update_interval", kind: "message", T: () =>
|
|
1320
|
+
{ no: 2, name: "update_interval", kind: "message", T: () => _ }
|
|
1321
1321
|
]
|
|
1322
1322
|
);
|
|
1323
1323
|
}
|
|
@@ -1340,7 +1340,7 @@ class Kt extends g {
|
|
|
1340
1340
|
break;
|
|
1341
1341
|
case /* google.protobuf.Duration update_interval */
|
|
1342
1342
|
2:
|
|
1343
|
-
o.updateInterval =
|
|
1343
|
+
o.updateInterval = _.internalBinaryRead(
|
|
1344
1344
|
e,
|
|
1345
1345
|
e.uint32(),
|
|
1346
1346
|
r,
|
|
@@ -1366,7 +1366,7 @@ class Kt extends g {
|
|
|
1366
1366
|
return o;
|
|
1367
1367
|
}
|
|
1368
1368
|
internalBinaryWrite(e, t, r) {
|
|
1369
|
-
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval &&
|
|
1369
|
+
e.resourceId !== 0n && t.tag(1, h.Varint).uint64(e.resourceId), e.updateInterval && _.internalBinaryWrite(
|
|
1370
1370
|
e.updateInterval,
|
|
1371
1371
|
t.tag(2, h.LengthDelimited).fork(),
|
|
1372
1372
|
r
|
|
@@ -1384,7 +1384,7 @@ class tr extends g {
|
|
|
1384
1384
|
constructor() {
|
|
1385
1385
|
super(
|
|
1386
1386
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
|
|
1387
|
-
[{ no: 1, name: "report", kind: "message", T: () =>
|
|
1387
|
+
[{ no: 1, name: "report", kind: "message", T: () => S }]
|
|
1388
1388
|
);
|
|
1389
1389
|
}
|
|
1390
1390
|
create(e) {
|
|
@@ -1402,7 +1402,7 @@ class tr extends g {
|
|
|
1402
1402
|
switch (i) {
|
|
1403
1403
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1404
1404
|
1:
|
|
1405
|
-
o.report =
|
|
1405
|
+
o.report = S.internalBinaryRead(
|
|
1406
1406
|
e,
|
|
1407
1407
|
e.uint32(),
|
|
1408
1408
|
r,
|
|
@@ -1428,7 +1428,7 @@ class tr extends g {
|
|
|
1428
1428
|
return o;
|
|
1429
1429
|
}
|
|
1430
1430
|
internalBinaryWrite(e, t, r) {
|
|
1431
|
-
e.report &&
|
|
1431
|
+
e.report && S.internalBinaryWrite(
|
|
1432
1432
|
e.report,
|
|
1433
1433
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1434
1434
|
r
|
|
@@ -1441,7 +1441,7 @@ class tr extends g {
|
|
|
1441
1441
|
), t;
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
|
-
const rr = new tr(), A = new
|
|
1444
|
+
const rr = new tr(), A = new B(
|
|
1445
1445
|
"MiLaboratories.Controller.Shared.Progress",
|
|
1446
1446
|
[
|
|
1447
1447
|
{
|
|
@@ -1495,7 +1495,7 @@ class or {
|
|
|
1495
1495
|
const n = await this.grpcClient.getStatus(
|
|
1496
1496
|
{ resourceId: e },
|
|
1497
1497
|
T(t, r)
|
|
1498
|
-
), o =
|
|
1498
|
+
), o = re(n.response.report);
|
|
1499
1499
|
return {
|
|
1500
1500
|
done: o.done,
|
|
1501
1501
|
progress: o.progress,
|
|
@@ -1507,7 +1507,7 @@ class or {
|
|
|
1507
1507
|
// GRPC stream every updateIntervalMs milliseconds.
|
|
1508
1508
|
async *realtimeStatus({ id: e, type: t }, r = 100, n) {
|
|
1509
1509
|
n = T(t, n);
|
|
1510
|
-
const o = Math.floor(r / 1e3), l = (r - o * 1e3) * 1e6, i =
|
|
1510
|
+
const o = Math.floor(r / 1e3), l = (r - o * 1e3) * 1e6, i = _.create({
|
|
1511
1511
|
seconds: BigInt(o),
|
|
1512
1512
|
nanos: l
|
|
1513
1513
|
});
|
|
@@ -1525,7 +1525,7 @@ class or {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
}
|
|
1527
1527
|
}
|
|
1528
|
-
class
|
|
1528
|
+
class de extends Error {
|
|
1529
1529
|
}
|
|
1530
1530
|
class ve {
|
|
1531
1531
|
constructor(e) {
|
|
@@ -1536,7 +1536,7 @@ class ve {
|
|
|
1536
1536
|
dispatcher: this.httpClient,
|
|
1537
1537
|
headers: t,
|
|
1538
1538
|
signal: r
|
|
1539
|
-
}), i =
|
|
1539
|
+
}), i = ie.toWeb(o);
|
|
1540
1540
|
return await sr(n, i, e), {
|
|
1541
1541
|
content: i,
|
|
1542
1542
|
size: Number(l["content-length"])
|
|
@@ -1546,13 +1546,13 @@ class ve {
|
|
|
1546
1546
|
async function sr(s, e, t) {
|
|
1547
1547
|
if (s != 200) {
|
|
1548
1548
|
const r = (await nt(e)).substring(0, 1e3);
|
|
1549
|
-
throw 400 <= s && s < 500 ? new
|
|
1549
|
+
throw 400 <= s && s < 500 ? new de(
|
|
1550
1550
|
`Http error: statusCode: ${s} url: ${t.toString()}, beginning of body: ${r}`
|
|
1551
1551
|
) : new Error(`Http error: statusCode: ${s} url: ${t.toString()}`);
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1555
|
-
if (!
|
|
1554
|
+
function D(s) {
|
|
1555
|
+
if (!X.isAbsolute(s)) throw new Error(`Path ${s} is not absolute.`);
|
|
1556
1556
|
return s;
|
|
1557
1557
|
}
|
|
1558
1558
|
class ir extends g {
|
|
@@ -1816,7 +1816,7 @@ class hr extends g {
|
|
|
1816
1816
|
), t;
|
|
1817
1817
|
}
|
|
1818
1818
|
}
|
|
1819
|
-
const ur = new hr(),
|
|
1819
|
+
const ur = new hr(), M = new B(
|
|
1820
1820
|
"MiLaboratories.Controller.Shared.Download",
|
|
1821
1821
|
[
|
|
1822
1822
|
{
|
|
@@ -1831,9 +1831,9 @@ const ur = new hr(), z = new D(
|
|
|
1831
1831
|
);
|
|
1832
1832
|
class pr {
|
|
1833
1833
|
constructor(e) {
|
|
1834
|
-
d(this, "typeName",
|
|
1835
|
-
d(this, "methods",
|
|
1836
|
-
d(this, "options",
|
|
1834
|
+
d(this, "typeName", M.typeName);
|
|
1835
|
+
d(this, "methods", M.methods);
|
|
1836
|
+
d(this, "options", M.options);
|
|
1837
1837
|
this._transport = e;
|
|
1838
1838
|
}
|
|
1839
1839
|
/**
|
|
@@ -1861,7 +1861,7 @@ class gr {
|
|
|
1861
1861
|
async readLocalFile(e) {
|
|
1862
1862
|
const { storageId: t, relativePath: r } = fr(e), n = mr(t, this.localStorageIdsToRoot, r);
|
|
1863
1863
|
return {
|
|
1864
|
-
content:
|
|
1864
|
+
content: ie.toWeb(se.createReadStream(n)),
|
|
1865
1865
|
size: (await m.stat(n)).size
|
|
1866
1866
|
};
|
|
1867
1867
|
}
|
|
@@ -1898,7 +1898,7 @@ class _e extends Error {
|
|
|
1898
1898
|
function br(s) {
|
|
1899
1899
|
const e = /* @__PURE__ */ new Map();
|
|
1900
1900
|
for (const t of s)
|
|
1901
|
-
t.localPath !== "" &&
|
|
1901
|
+
t.localPath !== "" && D(t.localPath), e.set(t.storageId, t.localPath);
|
|
1902
1902
|
return e;
|
|
1903
1903
|
}
|
|
1904
1904
|
class kr extends g {
|
|
@@ -1926,14 +1926,14 @@ class kr extends g {
|
|
|
1926
1926
|
*/
|
|
1927
1927
|
now() {
|
|
1928
1928
|
const e = this.create(), t = Date.now();
|
|
1929
|
-
return e.seconds =
|
|
1929
|
+
return e.seconds = I.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
|
|
1930
1930
|
}
|
|
1931
1931
|
/**
|
|
1932
1932
|
* Converts a `Timestamp` to a JavaScript Date.
|
|
1933
1933
|
*/
|
|
1934
1934
|
toDate(e) {
|
|
1935
1935
|
return new Date(
|
|
1936
|
-
|
|
1936
|
+
I.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
|
|
1937
1937
|
);
|
|
1938
1938
|
}
|
|
1939
1939
|
/**
|
|
@@ -1941,14 +1941,14 @@ class kr extends g {
|
|
|
1941
1941
|
*/
|
|
1942
1942
|
fromDate(e) {
|
|
1943
1943
|
const t = this.create(), r = e.getTime();
|
|
1944
|
-
return t.seconds =
|
|
1944
|
+
return t.seconds = I.from(Math.floor(r / 1e3)).toBigInt(), t.nanos = r % 1e3 * 1e6, t;
|
|
1945
1945
|
}
|
|
1946
1946
|
/**
|
|
1947
1947
|
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1948
1948
|
* in the RFC 3339 format.
|
|
1949
1949
|
*/
|
|
1950
1950
|
internalJsonWrite(e, t) {
|
|
1951
|
-
let r =
|
|
1951
|
+
let r = I.from(e.seconds).toNumber() * 1e3;
|
|
1952
1952
|
if (r < Date.parse("0001-01-01T00:00:00Z") || r > Date.parse("9999-12-31T23:59:59Z"))
|
|
1953
1953
|
throw new Error(
|
|
1954
1954
|
"Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
@@ -1987,7 +1987,7 @@ class kr extends g {
|
|
|
1987
1987
|
throw new globalThis.Error(
|
|
1988
1988
|
"Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
1989
1989
|
);
|
|
1990
|
-
return r || (r = this.create()), r.seconds =
|
|
1990
|
+
return r || (r = this.create()), r.seconds = I.from(o / 1e3).toBigInt(), r.nanos = 0, n[7] && (r.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), r;
|
|
1991
1991
|
}
|
|
1992
1992
|
create(e) {
|
|
1993
1993
|
const t = globalThis.Object.create(this.messagePrototype);
|
|
@@ -2034,7 +2034,7 @@ class kr extends g {
|
|
|
2034
2034
|
), t;
|
|
2035
2035
|
}
|
|
2036
2036
|
}
|
|
2037
|
-
const
|
|
2037
|
+
const H = new kr();
|
|
2038
2038
|
class Tr extends g {
|
|
2039
2039
|
constructor() {
|
|
2040
2040
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
@@ -2095,7 +2095,7 @@ class Lr extends g {
|
|
|
2095
2095
|
T: 9
|
|
2096
2096
|
/*ScalarType.STRING*/
|
|
2097
2097
|
},
|
|
2098
|
-
{ no: 12, name: "last_modified", kind: "message", T: () =>
|
|
2098
|
+
{ no: 12, name: "last_modified", kind: "message", T: () => H },
|
|
2099
2099
|
{
|
|
2100
2100
|
no: 13,
|
|
2101
2101
|
name: "version",
|
|
@@ -2136,7 +2136,7 @@ class Lr extends g {
|
|
|
2136
2136
|
break;
|
|
2137
2137
|
case /* google.protobuf.Timestamp last_modified */
|
|
2138
2138
|
12:
|
|
2139
|
-
o.lastModified =
|
|
2139
|
+
o.lastModified = H.internalBinaryRead(
|
|
2140
2140
|
e,
|
|
2141
2141
|
e.uint32(),
|
|
2142
2142
|
r,
|
|
@@ -2166,7 +2166,7 @@ class Lr extends g {
|
|
|
2166
2166
|
return o;
|
|
2167
2167
|
}
|
|
2168
2168
|
internalBinaryWrite(e, t, r) {
|
|
2169
|
-
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 &&
|
|
2169
|
+
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 && H.internalBinaryWrite(
|
|
2170
2170
|
e.lastModified,
|
|
2171
2171
|
t.tag(12, h.LengthDelimited).fork(),
|
|
2172
2172
|
r
|
|
@@ -2179,7 +2179,7 @@ class Lr extends g {
|
|
|
2179
2179
|
), t;
|
|
2180
2180
|
}
|
|
2181
2181
|
}
|
|
2182
|
-
const
|
|
2182
|
+
const j = new Lr();
|
|
2183
2183
|
class Pr extends g {
|
|
2184
2184
|
constructor() {
|
|
2185
2185
|
super("MiLaboratories.Controller.Shared.LsAPI.List", []);
|
|
@@ -2275,7 +2275,7 @@ class Sr extends g {
|
|
|
2275
2275
|
name: "items",
|
|
2276
2276
|
kind: "message",
|
|
2277
2277
|
repeat: 1,
|
|
2278
|
-
T: () =>
|
|
2278
|
+
T: () => j
|
|
2279
2279
|
},
|
|
2280
2280
|
{
|
|
2281
2281
|
no: 2,
|
|
@@ -2298,7 +2298,7 @@ class Sr extends g {
|
|
|
2298
2298
|
case /* repeated MiLaboratories.Controller.Shared.LsAPI.ListItem items */
|
|
2299
2299
|
1:
|
|
2300
2300
|
o.items.push(
|
|
2301
|
-
|
|
2301
|
+
j.internalBinaryRead(e, e.uint32(), r)
|
|
2302
2302
|
);
|
|
2303
2303
|
break;
|
|
2304
2304
|
case /* string delimiter */
|
|
@@ -2325,7 +2325,7 @@ class Sr extends g {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
internalBinaryWrite(e, t, r) {
|
|
2327
2327
|
for (let o = 0; o < e.items.length; o++)
|
|
2328
|
-
|
|
2328
|
+
j.internalBinaryWrite(
|
|
2329
2329
|
e.items[o],
|
|
2330
2330
|
t.tag(1, h.LengthDelimited).fork(),
|
|
2331
2331
|
r
|
|
@@ -2339,14 +2339,14 @@ class Sr extends g {
|
|
|
2339
2339
|
), t;
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
|
-
const Ur = new Sr(),
|
|
2342
|
+
const Ur = new Sr(), G = new B("MiLaboratories.Controller.Shared.LS", [
|
|
2343
2343
|
{ name: "List", options: {}, I: Rr, O: Ur }
|
|
2344
2344
|
]);
|
|
2345
2345
|
class Nr {
|
|
2346
2346
|
constructor(e) {
|
|
2347
|
-
d(this, "typeName",
|
|
2348
|
-
d(this, "methods",
|
|
2349
|
-
d(this, "options",
|
|
2347
|
+
d(this, "typeName", G.typeName);
|
|
2348
|
+
d(this, "methods", G.methods);
|
|
2349
|
+
d(this, "options", G.options);
|
|
2350
2350
|
this._transport = e;
|
|
2351
2351
|
}
|
|
2352
2352
|
/**
|
|
@@ -2780,7 +2780,7 @@ class Er extends g {
|
|
|
2780
2780
|
}
|
|
2781
2781
|
}
|
|
2782
2782
|
const Wr = new Er();
|
|
2783
|
-
class
|
|
2783
|
+
class zr extends g {
|
|
2784
2784
|
constructor() {
|
|
2785
2785
|
super("MiLaboratories.Controller.Shared.StreamingAPI.LastLines", [
|
|
2786
2786
|
{
|
|
@@ -2883,8 +2883,8 @@ class Ar extends g {
|
|
|
2883
2883
|
), t;
|
|
2884
2884
|
}
|
|
2885
2885
|
}
|
|
2886
|
-
const
|
|
2887
|
-
class
|
|
2886
|
+
const Ar = new zr();
|
|
2887
|
+
class xr extends g {
|
|
2888
2888
|
constructor() {
|
|
2889
2889
|
super("MiLaboratories.Controller.Shared.StreamingAPI.Response", [
|
|
2890
2890
|
{
|
|
@@ -2961,7 +2961,7 @@ class zr extends g {
|
|
|
2961
2961
|
), t;
|
|
2962
2962
|
}
|
|
2963
2963
|
}
|
|
2964
|
-
const
|
|
2964
|
+
const U = new xr(), V = new B(
|
|
2965
2965
|
"MiLaboratories.Controller.Shared.Streaming",
|
|
2966
2966
|
[
|
|
2967
2967
|
{
|
|
@@ -2969,40 +2969,40 @@ const S = new zr(), G = new D(
|
|
|
2969
2969
|
serverStreaming: !0,
|
|
2970
2970
|
options: {},
|
|
2971
2971
|
I: $r,
|
|
2972
|
-
O:
|
|
2972
|
+
O: U
|
|
2973
2973
|
},
|
|
2974
2974
|
{
|
|
2975
2975
|
name: "ReadBinary",
|
|
2976
2976
|
options: {},
|
|
2977
2977
|
I: Cr,
|
|
2978
|
-
O:
|
|
2978
|
+
O: U
|
|
2979
2979
|
},
|
|
2980
2980
|
{
|
|
2981
2981
|
name: "StreamText",
|
|
2982
2982
|
serverStreaming: !0,
|
|
2983
2983
|
options: {},
|
|
2984
2984
|
I: Fr,
|
|
2985
|
-
O:
|
|
2985
|
+
O: U
|
|
2986
2986
|
},
|
|
2987
2987
|
{
|
|
2988
2988
|
name: "ReadText",
|
|
2989
2989
|
options: {},
|
|
2990
2990
|
I: Wr,
|
|
2991
|
-
O:
|
|
2991
|
+
O: U
|
|
2992
2992
|
},
|
|
2993
2993
|
{
|
|
2994
2994
|
name: "LastLines",
|
|
2995
2995
|
options: {},
|
|
2996
|
-
I:
|
|
2997
|
-
O:
|
|
2996
|
+
I: Ar,
|
|
2997
|
+
O: U
|
|
2998
2998
|
}
|
|
2999
2999
|
]
|
|
3000
3000
|
);
|
|
3001
3001
|
class Mr {
|
|
3002
3002
|
constructor(e) {
|
|
3003
|
-
d(this, "typeName",
|
|
3004
|
-
d(this, "methods",
|
|
3005
|
-
d(this, "options",
|
|
3003
|
+
d(this, "typeName", V.typeName);
|
|
3004
|
+
d(this, "methods", V.methods);
|
|
3005
|
+
d(this, "options", V.options);
|
|
3006
3006
|
this._transport = e;
|
|
3007
3007
|
}
|
|
3008
3008
|
/**
|
|
@@ -3124,7 +3124,7 @@ class Hr {
|
|
|
3124
3124
|
async readText({ id: e, type: t }, r, n = 0n, o, l) {
|
|
3125
3125
|
return (await this.grpcClient.readText(
|
|
3126
3126
|
{
|
|
3127
|
-
resourceId:
|
|
3127
|
+
resourceId: re(e),
|
|
3128
3128
|
readLimit: BigInt(r),
|
|
3129
3129
|
offset: n,
|
|
3130
3130
|
search: o
|
|
@@ -3154,7 +3154,7 @@ function eo(s, e) {
|
|
|
3154
3154
|
function to(s, e) {
|
|
3155
3155
|
return s.getDriver({
|
|
3156
3156
|
name: "UploadBlob",
|
|
3157
|
-
init: (t, r, n) => new
|
|
3157
|
+
init: (t, r, n) => new zt(r, n, s, e)
|
|
3158
3158
|
});
|
|
3159
3159
|
}
|
|
3160
3160
|
function jr(s, e) {
|
|
@@ -3165,8 +3165,8 @@ function jr(s, e) {
|
|
|
3165
3165
|
}
|
|
3166
3166
|
class Gr {
|
|
3167
3167
|
constructor(e, t, r, n, o) {
|
|
3168
|
-
d(this, "counter", new
|
|
3169
|
-
d(this, "change", new
|
|
3168
|
+
d(this, "counter", new v());
|
|
3169
|
+
d(this, "change", new $());
|
|
3170
3170
|
d(this, "signalCtl", new AbortController());
|
|
3171
3171
|
d(this, "error");
|
|
3172
3172
|
d(this, "done", !1);
|
|
@@ -3174,21 +3174,36 @@ class Gr {
|
|
|
3174
3174
|
d(this, "size", 0);
|
|
3175
3175
|
this.logger = e, this.clientDownload = t, this.rInfo = r, this.path = n, this.handle = o;
|
|
3176
3176
|
}
|
|
3177
|
+
/** Returns a simple object that describes this task. */
|
|
3178
|
+
info() {
|
|
3179
|
+
return {
|
|
3180
|
+
rInfo: this.rInfo,
|
|
3181
|
+
path: this.path,
|
|
3182
|
+
done: this.done,
|
|
3183
|
+
size: this.size,
|
|
3184
|
+
error: this.error
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3177
3187
|
attach(e, t) {
|
|
3178
3188
|
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
3179
3189
|
}
|
|
3180
3190
|
async download() {
|
|
3181
3191
|
try {
|
|
3182
|
-
await
|
|
3183
|
-
|
|
3184
|
-
await Le(this.path) ? await e.cancel("the file already exists.") : await Pe(this.logger, this.path, async (r) => {
|
|
3185
|
-
const n = ie.toWeb(tt.createWriteStream(r, { flags: "wx" }));
|
|
3186
|
-
await e.pipeTo(n);
|
|
3187
|
-
}), this.setDone(t), this.change.markChanged();
|
|
3192
|
+
const e = await this.ensureDownloaded();
|
|
3193
|
+
this.setDone(e), this.change.markChanged();
|
|
3188
3194
|
} catch (e) {
|
|
3189
3195
|
throw Ce(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
|
|
3190
3196
|
}
|
|
3191
3197
|
}
|
|
3198
|
+
async ensureDownloaded() {
|
|
3199
|
+
if (await Te(w.dirname(this.path)), await Le(this.path))
|
|
3200
|
+
return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
|
|
3201
|
+
const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
|
|
3202
|
+
return await Pe(this.logger, this.path, async (r) => {
|
|
3203
|
+
const n = ae.toWeb(tt.createWriteStream(r, { flags: "wx" }));
|
|
3204
|
+
await e.pipeTo(n);
|
|
3205
|
+
}), t;
|
|
3206
|
+
}
|
|
3192
3207
|
abort(e) {
|
|
3193
3208
|
this.signalCtl.abort(new Oe(e));
|
|
3194
3209
|
}
|
|
@@ -3215,7 +3230,7 @@ class Gr {
|
|
|
3215
3230
|
}
|
|
3216
3231
|
}
|
|
3217
3232
|
function Ce(s) {
|
|
3218
|
-
return s instanceof Oe || s instanceof
|
|
3233
|
+
return s instanceof Oe || s instanceof de || s instanceof _e || s instanceof $e || // file that we downloads from was moved or deleted.
|
|
3219
3234
|
(s == null ? void 0 : s.code) == "ENOENT" || // A resource was deleted.
|
|
3220
3235
|
s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED");
|
|
3221
3236
|
}
|
|
@@ -3237,7 +3252,7 @@ class Fe {
|
|
|
3237
3252
|
/** Decrements a counter in a cache and if we exceeds
|
|
3238
3253
|
* a soft limit, removes files with zero counters. */
|
|
3239
3254
|
removeFile(e, t) {
|
|
3240
|
-
return
|
|
3255
|
+
return ue(this.cache, e).counter.dec(t), this.toDelete();
|
|
3241
3256
|
}
|
|
3242
3257
|
/** Returns what results should be deleted to comply with the soft limit. */
|
|
3243
3258
|
toDelete() {
|
|
@@ -3246,7 +3261,7 @@ class Fe {
|
|
|
3246
3261
|
let t = 0;
|
|
3247
3262
|
return Ke(this.cache).filter(([r, n]) => n.counter.isZero()).forEach(([r, n]) => {
|
|
3248
3263
|
if (this.totalSizeBytes - t <= this.softSizeBytes) return;
|
|
3249
|
-
const o =
|
|
3264
|
+
const o = ue(this.cache, r);
|
|
3250
3265
|
t += o.size, e.push(o);
|
|
3251
3266
|
}), e;
|
|
3252
3267
|
}
|
|
@@ -3266,14 +3281,14 @@ function Vr(s, e) {
|
|
|
3266
3281
|
function qr(s) {
|
|
3267
3282
|
return !!s.match(Ee);
|
|
3268
3283
|
}
|
|
3269
|
-
function
|
|
3284
|
+
function q(s, e) {
|
|
3270
3285
|
const t = s.match(Ee);
|
|
3271
3286
|
if (t === null)
|
|
3272
3287
|
throw new Error(`Local handle is malformed: ${s}, matches: ${t}`);
|
|
3273
3288
|
const { path: r, signature: n } = t.groups;
|
|
3274
3289
|
return e.verify(r, n, `Signature verification failed for: ${s}`), { path: r, signature: n };
|
|
3275
3290
|
}
|
|
3276
|
-
const Jr =
|
|
3291
|
+
const Jr = le({
|
|
3277
3292
|
kv: {
|
|
3278
3293
|
"ctl/file/blobInfo": k.object({
|
|
3279
3294
|
sizeBytes: k.coerce.number()
|
|
@@ -3283,7 +3298,7 @@ const Jr = ae({
|
|
|
3283
3298
|
function Zr(s) {
|
|
3284
3299
|
return s.kv["ctl/file/blobInfo"].sizeBytes;
|
|
3285
3300
|
}
|
|
3286
|
-
const
|
|
3301
|
+
const F = k.object({
|
|
3287
3302
|
/** Local file path, to take data for upload */
|
|
3288
3303
|
localPath: k.string(),
|
|
3289
3304
|
/** Path signature, to check this data was generated by us */
|
|
@@ -3298,61 +3313,61 @@ const O = k.object({
|
|
|
3298
3313
|
/** Path inside storage */
|
|
3299
3314
|
path: k.string()
|
|
3300
3315
|
}), ro = k.union([
|
|
3301
|
-
|
|
3316
|
+
F,
|
|
3302
3317
|
We
|
|
3303
|
-
]), Qr =
|
|
3304
|
-
data:
|
|
3318
|
+
]), Qr = le({
|
|
3319
|
+
data: F,
|
|
3305
3320
|
fields: {
|
|
3306
3321
|
blob: !1
|
|
3307
3322
|
}
|
|
3308
|
-
}), Xr =
|
|
3323
|
+
}), Xr = le({
|
|
3309
3324
|
fields: {
|
|
3310
3325
|
incarnation: !1
|
|
3311
3326
|
}
|
|
3312
|
-
}),
|
|
3327
|
+
}), ze = /^blob\+remote:\/\/download\/(?<content>(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*))#(?<signature>.*)$/;
|
|
3313
3328
|
function Yr(s, e) {
|
|
3314
3329
|
const t = `${s.type.name}/${s.type.version}/${BigInt(s.id)}`;
|
|
3315
3330
|
return `blob+remote://download/${t}#${e.sign(t)}`;
|
|
3316
3331
|
}
|
|
3317
3332
|
function Kr(s) {
|
|
3318
|
-
return !!s.match(
|
|
3333
|
+
return !!s.match(ze);
|
|
3319
3334
|
}
|
|
3320
3335
|
function en(s, e) {
|
|
3321
|
-
const t = s.match(
|
|
3336
|
+
const t = s.match(ze);
|
|
3322
3337
|
if (t === null)
|
|
3323
3338
|
throw new Error(`Remote handle is malformed: ${s}, matches: ${t}`);
|
|
3324
3339
|
const { content: r, resourceType: n, resourceVersion: o, resourceId: l, signature: i } = t.groups;
|
|
3325
3340
|
return e.verify(r, i, `Signature verification failed for ${s}`), {
|
|
3326
|
-
id:
|
|
3341
|
+
id: te(BigInt(l)),
|
|
3327
3342
|
type: { name: n, version: o }
|
|
3328
3343
|
};
|
|
3329
3344
|
}
|
|
3330
|
-
function
|
|
3345
|
+
function Ae(s, e) {
|
|
3331
3346
|
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)}`;
|
|
3332
3347
|
}
|
|
3333
|
-
const
|
|
3334
|
-
function
|
|
3335
|
-
return
|
|
3348
|
+
const xe = /^log\+live:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3349
|
+
function C(s) {
|
|
3350
|
+
return xe.test(s);
|
|
3336
3351
|
}
|
|
3337
3352
|
const Me = /^log\+ready:\/\/log\/(?<resourceType>.*)\/(?<resourceVersion>.*)\/(?<resourceId>.*)$/;
|
|
3338
3353
|
function tn(s) {
|
|
3339
3354
|
return Me.test(s);
|
|
3340
3355
|
}
|
|
3341
|
-
function
|
|
3356
|
+
function O(s) {
|
|
3342
3357
|
let e;
|
|
3343
|
-
if (
|
|
3344
|
-
e = s.match(
|
|
3358
|
+
if (C(s))
|
|
3359
|
+
e = s.match(xe);
|
|
3345
3360
|
else if (tn(s))
|
|
3346
3361
|
e = s.match(Me);
|
|
3347
3362
|
else throw new Error(`Log handle is malformed: ${s}`);
|
|
3348
3363
|
if (e == null) throw new Error(`Log handle wasn't parsed: ${s}`);
|
|
3349
3364
|
const { resourceType: t, resourceVersion: r, resourceId: n } = e.groups;
|
|
3350
3365
|
return {
|
|
3351
|
-
id:
|
|
3366
|
+
id: te(BigInt(n)),
|
|
3352
3367
|
type: { name: t, version: r }
|
|
3353
3368
|
};
|
|
3354
3369
|
}
|
|
3355
|
-
class
|
|
3370
|
+
class he extends Error {
|
|
3356
3371
|
}
|
|
3357
3372
|
class rn {
|
|
3358
3373
|
constructor(e) {
|
|
@@ -3384,17 +3399,17 @@ class no {
|
|
|
3384
3399
|
d(this, "idToLastLines", /* @__PURE__ */ new Map());
|
|
3385
3400
|
d(this, "idToProgressLog", /* @__PURE__ */ new Map());
|
|
3386
3401
|
d(this, "saveDir");
|
|
3387
|
-
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.signer = o, this.cache = new Fe(l.cacheSoftSizeBytes), this.downloadQueue = new
|
|
3402
|
+
this.logger = e, this.clientDownload = t, this.clientLogs = r, this.signer = o, this.cache = new Fe(l.cacheSoftSizeBytes), this.downloadQueue = new ne(this.logger, l.nConcurrentDownloads), this.saveDir = w.resolve(n);
|
|
3388
3403
|
}
|
|
3389
3404
|
getDownloadedBlob(e, t) {
|
|
3390
3405
|
if (t === void 0) return b.make((l) => this.getDownloadedBlob(e, l));
|
|
3391
|
-
const r =
|
|
3406
|
+
const r = R(e, t), n = P();
|
|
3392
3407
|
t.addOnDestroy(() => this.releaseBlob(r.id, n));
|
|
3393
3408
|
const o = this.getDownloadedBlobNoCtx(t.watcher, r, n);
|
|
3394
3409
|
return o == null && t.markUnstable("download blob is still undefined"), o;
|
|
3395
3410
|
}
|
|
3396
3411
|
getDownloadedBlobNoCtx(e, t, r) {
|
|
3397
|
-
|
|
3412
|
+
N("getDownloadedBlob", t.type);
|
|
3398
3413
|
let n = this.idToDownload.get(t.id);
|
|
3399
3414
|
if (n === void 0) {
|
|
3400
3415
|
const l = this.setNewDownloadTask(t);
|
|
@@ -3427,17 +3442,17 @@ class no {
|
|
|
3427
3442
|
}
|
|
3428
3443
|
getOnDemandBlob(e, t) {
|
|
3429
3444
|
if (t === void 0) return b.make((l) => this.getOnDemandBlob(e, l));
|
|
3430
|
-
const r =
|
|
3445
|
+
const r = ce(e) ? Y(e, Jr, t) : e, n = P();
|
|
3431
3446
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(r.id, n)), this.getOnDemandBlobNoCtx(r, n);
|
|
3432
3447
|
}
|
|
3433
3448
|
getOnDemandBlobNoCtx(e, t) {
|
|
3434
|
-
|
|
3449
|
+
N("getOnDemandBlob", e.type);
|
|
3435
3450
|
let r = this.idToOnDemand.get(e.id);
|
|
3436
3451
|
return r === void 0 && (r = new nn(Zr(e), Yr(e, this.signer)), this.idToOnDemand.set(e.id, r)), r.attach(t), r.getHandle();
|
|
3437
3452
|
}
|
|
3438
3453
|
/** Gets a path from a handle. */
|
|
3439
3454
|
getLocalPath(e) {
|
|
3440
|
-
const { path: t } =
|
|
3455
|
+
const { path: t } = q(e, this.signer);
|
|
3441
3456
|
return t;
|
|
3442
3457
|
}
|
|
3443
3458
|
/** Gets a content of a blob by a handle. */
|
|
@@ -3452,19 +3467,19 @@ class no {
|
|
|
3452
3467
|
}
|
|
3453
3468
|
getLastLogs(e, t, r) {
|
|
3454
3469
|
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
3455
|
-
const n =
|
|
3470
|
+
const n = R(e, r), o = P();
|
|
3456
3471
|
r.addOnDestroy(() => this.releaseBlob(n.id, o));
|
|
3457
3472
|
const l = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
3458
3473
|
return l == null && r.markUnstable("either a file was not downloaded or logs was not read"), l;
|
|
3459
3474
|
}
|
|
3460
3475
|
getLastLogsNoCtx(e, t, r, n) {
|
|
3461
|
-
|
|
3476
|
+
N("getLastLogs", t.type);
|
|
3462
3477
|
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3463
3478
|
if (o == null) return;
|
|
3464
|
-
const { path: l } =
|
|
3479
|
+
const { path: l } = q(o.handle, this.signer);
|
|
3465
3480
|
let i = this.idToLastLines.get(t.id);
|
|
3466
3481
|
if (i == null) {
|
|
3467
|
-
const a = new
|
|
3482
|
+
const a = new ge(l, r);
|
|
3468
3483
|
this.idToLastLines.set(t.id, a), i = a;
|
|
3469
3484
|
}
|
|
3470
3485
|
const c = i.getOrSchedule(e);
|
|
@@ -3474,7 +3489,7 @@ class no {
|
|
|
3474
3489
|
getProgressLog(e, t, r) {
|
|
3475
3490
|
if (r == null)
|
|
3476
3491
|
return b.make((i) => this.getProgressLog(e, t, i));
|
|
3477
|
-
const n =
|
|
3492
|
+
const n = R(e, r), o = P();
|
|
3478
3493
|
r.addOnDestroy(() => this.releaseBlob(n.id, o));
|
|
3479
3494
|
const l = this.getProgressLogNoCtx(
|
|
3480
3495
|
r.watcher,
|
|
@@ -3485,13 +3500,13 @@ class no {
|
|
|
3485
3500
|
return l === void 0 && r.markUnstable("either a file was not downloaded or a progress log was not read"), l;
|
|
3486
3501
|
}
|
|
3487
3502
|
getProgressLogNoCtx(e, t, r, n) {
|
|
3488
|
-
|
|
3503
|
+
N("getProgressLog", t.type);
|
|
3489
3504
|
const o = this.getDownloadedBlobNoCtx(e, t, n);
|
|
3490
3505
|
if (o == null) return;
|
|
3491
|
-
const { path: l } =
|
|
3506
|
+
const { path: l } = q(o.handle, this.signer);
|
|
3492
3507
|
let i = this.idToProgressLog.get(t.id);
|
|
3493
3508
|
if (i == null) {
|
|
3494
|
-
const a = new
|
|
3509
|
+
const a = new ge(l, 1, r);
|
|
3495
3510
|
this.idToProgressLog.set(t.id, a), i = a;
|
|
3496
3511
|
}
|
|
3497
3512
|
const c = i.getOrSchedule(e);
|
|
@@ -3500,15 +3515,15 @@ class no {
|
|
|
3500
3515
|
}
|
|
3501
3516
|
getLogHandle(e, t) {
|
|
3502
3517
|
if (t == null) return b.make((n) => this.getLogHandle(e, n));
|
|
3503
|
-
const r =
|
|
3518
|
+
const r = R(e, t);
|
|
3504
3519
|
return this.getLogHandleNoCtx(r);
|
|
3505
3520
|
}
|
|
3506
3521
|
getLogHandleNoCtx(e) {
|
|
3507
|
-
return
|
|
3522
|
+
return N("getLogHandle", e.type), Ae(!1, e);
|
|
3508
3523
|
}
|
|
3509
3524
|
async lastLines(e, t, r, n) {
|
|
3510
3525
|
const o = await this.clientLogs.lastLines(
|
|
3511
|
-
|
|
3526
|
+
O(e),
|
|
3512
3527
|
t,
|
|
3513
3528
|
BigInt(r ?? 0),
|
|
3514
3529
|
n
|
|
@@ -3523,7 +3538,7 @@ class no {
|
|
|
3523
3538
|
}
|
|
3524
3539
|
async readText(e, t, r, n) {
|
|
3525
3540
|
const o = await this.clientLogs.readText(
|
|
3526
|
-
|
|
3541
|
+
O(e),
|
|
3527
3542
|
t,
|
|
3528
3543
|
BigInt(r ?? 0),
|
|
3529
3544
|
n
|
|
@@ -3545,12 +3560,15 @@ class no {
|
|
|
3545
3560
|
n.map(async (o) => {
|
|
3546
3561
|
await m.rm(o.path), this.cache.removeCache(o), this.removeTask(
|
|
3547
3562
|
o,
|
|
3548
|
-
`the task ${o.
|
|
3563
|
+
`the task ${L(o.info())} was removedfrom cache along with ${L(n.map((l) => l.info()))}`
|
|
3549
3564
|
);
|
|
3550
3565
|
})
|
|
3551
3566
|
);
|
|
3552
3567
|
} else
|
|
3553
|
-
r.counter.dec(t) && this.removeTask(
|
|
3568
|
+
r.counter.dec(t) && this.removeTask(
|
|
3569
|
+
r,
|
|
3570
|
+
`the task ${L(r.info())} was removed from cache`
|
|
3571
|
+
);
|
|
3554
3572
|
}
|
|
3555
3573
|
removeTask(e, t) {
|
|
3556
3574
|
e.abort(t), e.change.markChanged(), this.idToDownload.delete(e.rInfo.id), this.idToLastLines.delete(e.rInfo.id), this.idToProgressLog.delete(e.rInfo.id);
|
|
@@ -3571,7 +3589,7 @@ class no {
|
|
|
3571
3589
|
}
|
|
3572
3590
|
class nn {
|
|
3573
3591
|
constructor(e, t) {
|
|
3574
|
-
d(this, "counter", new
|
|
3592
|
+
d(this, "counter", new v());
|
|
3575
3593
|
this.size = e, this.handle = t;
|
|
3576
3594
|
}
|
|
3577
3595
|
getHandle() {
|
|
@@ -3584,11 +3602,11 @@ class nn {
|
|
|
3584
3602
|
return this.counter.dec(e);
|
|
3585
3603
|
}
|
|
3586
3604
|
}
|
|
3587
|
-
class
|
|
3605
|
+
class ge {
|
|
3588
3606
|
constructor(e, t, r) {
|
|
3589
3607
|
d(this, "updater");
|
|
3590
3608
|
d(this, "log");
|
|
3591
|
-
d(this, "change", new
|
|
3609
|
+
d(this, "change", new $());
|
|
3592
3610
|
d(this, "error");
|
|
3593
3611
|
this.path = e, this.lines = t, this.patternToSearch = r, this.updater = new rn(async () => this.update());
|
|
3594
3612
|
}
|
|
@@ -3612,29 +3630,29 @@ class pe {
|
|
|
3612
3630
|
}
|
|
3613
3631
|
}
|
|
3614
3632
|
function on(s, e, t) {
|
|
3615
|
-
const r =
|
|
3633
|
+
const r = se.createReadStream(s), n = new ae();
|
|
3616
3634
|
return new Promise((o, l) => {
|
|
3617
3635
|
const i = lt.createInterface(r, n), c = new st();
|
|
3618
3636
|
i.on("line", function(a) {
|
|
3619
3637
|
t != null && !a.includes(t) || (c.push(a), c.length > e && c.shift());
|
|
3620
3638
|
}), i.on("error", l), i.on("close", function() {
|
|
3621
|
-
o(c.toArray().join(
|
|
3639
|
+
o(c.toArray().join(pe.EOL) + pe.EOL);
|
|
3622
3640
|
});
|
|
3623
3641
|
});
|
|
3624
3642
|
}
|
|
3625
3643
|
async function sn(s) {
|
|
3626
|
-
return await Ie(
|
|
3644
|
+
return await Ie(ie.toWeb(se.createReadStream(s)));
|
|
3627
3645
|
}
|
|
3628
|
-
function
|
|
3646
|
+
function N(s, e) {
|
|
3629
3647
|
if (!e.name.startsWith("Blob/")) {
|
|
3630
3648
|
let t = `${s}: wrong resource type: ${e.name}, expected: a resource of type that starts with 'Blob/'.`;
|
|
3631
|
-
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new
|
|
3649
|
+
throw e.name == "Blob" && (t += " If it's called from workflow, should a file be exported with 'file.exportFile' function?"), new he(t);
|
|
3632
3650
|
}
|
|
3633
3651
|
}
|
|
3634
3652
|
class an {
|
|
3635
3653
|
constructor(e, t, r, n, o, l) {
|
|
3636
|
-
d(this, "change", new
|
|
3637
|
-
d(this, "counter", new
|
|
3654
|
+
d(this, "change", new $());
|
|
3655
|
+
d(this, "counter", new v());
|
|
3638
3656
|
/** If this is upload progress this field will be defined */
|
|
3639
3657
|
d(this, "uploadData");
|
|
3640
3658
|
d(this, "progress");
|
|
@@ -3654,7 +3672,7 @@ class an {
|
|
|
3654
3672
|
}
|
|
3655
3673
|
/** Uploads a blob if it's not BlobIndex. */
|
|
3656
3674
|
async uploadBlobTask() {
|
|
3657
|
-
ct(
|
|
3675
|
+
ct(K(this.res), "the upload operation can be done only for BlobUploads");
|
|
3658
3676
|
try {
|
|
3659
3677
|
if (this.isComputableDone()) return;
|
|
3660
3678
|
const e = await this.clientBlob.initUpload(this.res);
|
|
@@ -3669,10 +3687,10 @@ class an {
|
|
|
3669
3687
|
r
|
|
3670
3688
|
), this.logger.info(`uploaded chunk ${r}/${e.overall} of resource: ${this.res.id}`));
|
|
3671
3689
|
};
|
|
3672
|
-
if (await
|
|
3690
|
+
if (await oe(this.nConcurrentPartsUpload, e.toUpload.map(t)), this.isComputableDone()) return;
|
|
3673
3691
|
await this.clientBlob.finalize(this.res), this.logger.info(`uploading of resource ${this.res.id} finished.`), this.change.markChanged();
|
|
3674
3692
|
} catch (e) {
|
|
3675
|
-
if (this.setRetriableError(e),
|
|
3693
|
+
if (this.setRetriableError(e), fe(e)) {
|
|
3676
3694
|
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3677
3695
|
return;
|
|
3678
3696
|
}
|
|
@@ -3692,9 +3710,9 @@ class an {
|
|
|
3692
3710
|
this.logger.warn("deadline exceeded while getting a status of BlobImport");
|
|
3693
3711
|
return;
|
|
3694
3712
|
}
|
|
3695
|
-
if (
|
|
3713
|
+
if (fe(e)) {
|
|
3696
3714
|
this.logger.warn(
|
|
3697
|
-
`resource was not found while updating a status of BlobImport: ${e}, ${
|
|
3715
|
+
`resource was not found while updating a status of BlobImport: ${e}, ${L(this.res)}`
|
|
3698
3716
|
), this.change.markChanged(), this.setDone(!0);
|
|
3699
3717
|
return;
|
|
3700
3718
|
}
|
|
@@ -3727,12 +3745,12 @@ class an {
|
|
|
3727
3745
|
}
|
|
3728
3746
|
function ln(s, e) {
|
|
3729
3747
|
let t, r;
|
|
3730
|
-
return
|
|
3748
|
+
return K(s) && (r = F.parse(s.data), t = hn(e, r.localPath, r.pathSignature)), {
|
|
3731
3749
|
uploadData: r,
|
|
3732
3750
|
progress: {
|
|
3733
3751
|
done: !1,
|
|
3734
3752
|
status: void 0,
|
|
3735
|
-
isUpload:
|
|
3753
|
+
isUpload: K(s),
|
|
3736
3754
|
isUploadSignMatch: t,
|
|
3737
3755
|
lastError: void 0
|
|
3738
3756
|
}
|
|
@@ -3744,7 +3762,7 @@ function cn(s) {
|
|
|
3744
3762
|
function dn(s) {
|
|
3745
3763
|
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
3746
3764
|
}
|
|
3747
|
-
function
|
|
3765
|
+
function K(s) {
|
|
3748
3766
|
return s.type.name.startsWith("BlobUpload");
|
|
3749
3767
|
}
|
|
3750
3768
|
function hn(s, e, t) {
|
|
@@ -3761,15 +3779,15 @@ function un(s) {
|
|
|
3761
3779
|
bytesTotal: Number(s.bytesTotal)
|
|
3762
3780
|
};
|
|
3763
3781
|
}
|
|
3764
|
-
function
|
|
3782
|
+
function fe(s) {
|
|
3765
3783
|
return s.name == "RpcError" && (s.code == "NOT_FOUND" || s.code == "ABORTED" || s.code == "ALREADY_EXISTS");
|
|
3766
3784
|
}
|
|
3767
3785
|
function He(s) {
|
|
3768
3786
|
return s instanceof Ne || s instanceof De || s instanceof Be;
|
|
3769
3787
|
}
|
|
3770
3788
|
function pn(s, e) {
|
|
3771
|
-
const t =
|
|
3772
|
-
return t.resourceType.name.startsWith("BlobUpload") ?
|
|
3789
|
+
const t = ce(s) ? e.accessor(s).node() : ot(s) ? s.node() : s;
|
|
3790
|
+
return t.resourceType.name.startsWith("BlobUpload") ? Y(t, Qr) : Y(t, Xr);
|
|
3773
3791
|
}
|
|
3774
3792
|
class oo {
|
|
3775
3793
|
constructor(e, t, r, n, o = {
|
|
@@ -3787,7 +3805,7 @@ class oo {
|
|
|
3787
3805
|
d(this, "keepRunning", !1);
|
|
3788
3806
|
/** Actual state of main loop. */
|
|
3789
3807
|
d(this, "currentLoop");
|
|
3790
|
-
this.logger = e, this.signer = t, this.clientBlob = r, this.clientProgress = n, this.opts = o, this.uploadQueue = new
|
|
3808
|
+
this.logger = e, this.signer = t, this.clientBlob = r, this.clientProgress = n, this.opts = o, this.uploadQueue = new ne(this.logger, 1, {
|
|
3791
3809
|
type: "exponentialWithMaxDelayBackoff",
|
|
3792
3810
|
initialDelay: 20,
|
|
3793
3811
|
maxDelay: 15e3,
|
|
@@ -3803,7 +3821,7 @@ class oo {
|
|
|
3803
3821
|
}
|
|
3804
3822
|
getProgressId(e, t) {
|
|
3805
3823
|
if (t == null) return b.make((l) => this.getProgressId(e, l));
|
|
3806
|
-
const r =
|
|
3824
|
+
const r = ce(e) ? pn(e, t) : e, n = P();
|
|
3807
3825
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(r.id, n)), this.getProgressIdNoCtx(t.watcher, r, n);
|
|
3808
3826
|
}
|
|
3809
3827
|
getProgressIdNoCtx(e, t, r) {
|
|
@@ -3850,7 +3868,7 @@ class oo {
|
|
|
3850
3868
|
const e = this.scheduledOnNextState;
|
|
3851
3869
|
this.scheduledOnNextState = [];
|
|
3852
3870
|
try {
|
|
3853
|
-
await
|
|
3871
|
+
await oe(
|
|
3854
3872
|
this.opts.nConcurrentGetProgresses,
|
|
3855
3873
|
this.getAllNotDoneProgresses().map((t) => async () => await t.updateStatus())
|
|
3856
3874
|
), e.forEach((t) => t.resolve());
|
|
@@ -3872,7 +3890,7 @@ function gn(s) {
|
|
|
3872
3890
|
}
|
|
3873
3891
|
function fn(s, e) {
|
|
3874
3892
|
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
3875
|
-
throw new
|
|
3893
|
+
throw new he(
|
|
3876
3894
|
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
3877
3895
|
);
|
|
3878
3896
|
}
|
|
@@ -3902,7 +3920,7 @@ class so {
|
|
|
3902
3920
|
}
|
|
3903
3921
|
getLastLogs(e, t, r) {
|
|
3904
3922
|
if (r == null) return b.make((i) => this.getLastLogs(e, t, i));
|
|
3905
|
-
const n =
|
|
3923
|
+
const n = R(e, r), o = P();
|
|
3906
3924
|
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseLastLogs(n.id, o));
|
|
3907
3925
|
const l = this.getLastLogsNoCtx(r.watcher, n, t, o);
|
|
3908
3926
|
return r.markUnstable(
|
|
@@ -3910,10 +3928,10 @@ class so {
|
|
|
3910
3928
|
), l;
|
|
3911
3929
|
}
|
|
3912
3930
|
getLastLogsNoCtx(e, t, r, n) {
|
|
3913
|
-
|
|
3931
|
+
J("getLastLogs", t.type);
|
|
3914
3932
|
let o = this.idToLastLines.get(t.id);
|
|
3915
3933
|
if (o == null) {
|
|
3916
|
-
const i = new
|
|
3934
|
+
const i = new me(this.logger, this.clientLogs, t, r);
|
|
3917
3935
|
this.idToLastLines.set(t.id, i), o = i;
|
|
3918
3936
|
}
|
|
3919
3937
|
o.attach(e, n);
|
|
@@ -3924,7 +3942,7 @@ class so {
|
|
|
3924
3942
|
getProgressLog(e, t, r) {
|
|
3925
3943
|
if (r == null)
|
|
3926
3944
|
return b.make((i) => this.getProgressLog(e, t, i));
|
|
3927
|
-
const n =
|
|
3945
|
+
const n = R(e, r), o = P();
|
|
3928
3946
|
r.attacheHooks(this.hooks), r.addOnDestroy(() => this.releaseProgressLog(n.id, o));
|
|
3929
3947
|
const l = this.getProgressLogNoCtx(r.watcher, n, t, o);
|
|
3930
3948
|
return r.markUnstable(
|
|
@@ -3932,10 +3950,10 @@ class so {
|
|
|
3932
3950
|
), l;
|
|
3933
3951
|
}
|
|
3934
3952
|
getProgressLogNoCtx(e, t, r, n) {
|
|
3935
|
-
|
|
3953
|
+
J("getProgressLog", t.type);
|
|
3936
3954
|
let o = this.idToProgressLog.get(t.id);
|
|
3937
3955
|
if (o == null) {
|
|
3938
|
-
const i = new
|
|
3956
|
+
const i = new me(this.logger, this.clientLogs, t, 1, r);
|
|
3939
3957
|
this.idToProgressLog.set(t.id, i), o = i;
|
|
3940
3958
|
}
|
|
3941
3959
|
o.attach(e, n);
|
|
@@ -3945,17 +3963,17 @@ class so {
|
|
|
3945
3963
|
}
|
|
3946
3964
|
getLogHandle(e, t) {
|
|
3947
3965
|
if (t == null) return b.make((o) => this.getLogHandle(e, o));
|
|
3948
|
-
const r =
|
|
3966
|
+
const r = R(e, t), n = this.getLogHandleNoCtx(r);
|
|
3949
3967
|
return t.markUnstable(`live_log:${Xe(r.id)}`), n;
|
|
3950
3968
|
}
|
|
3951
3969
|
getLogHandleNoCtx(e) {
|
|
3952
|
-
return
|
|
3970
|
+
return J("getLogHandle", e.type), Ae(!0, e);
|
|
3953
3971
|
}
|
|
3954
3972
|
async lastLines(e, t, r, n) {
|
|
3955
3973
|
return await this.tryWithNotFound(
|
|
3956
3974
|
e,
|
|
3957
3975
|
() => this.clientLogs.lastLines(
|
|
3958
|
-
|
|
3976
|
+
O(e),
|
|
3959
3977
|
t,
|
|
3960
3978
|
BigInt(r ?? 0),
|
|
3961
3979
|
n
|
|
@@ -3966,7 +3984,7 @@ class so {
|
|
|
3966
3984
|
return await this.tryWithNotFound(
|
|
3967
3985
|
e,
|
|
3968
3986
|
() => this.clientLogs.readText(
|
|
3969
|
-
|
|
3987
|
+
O(e),
|
|
3970
3988
|
t,
|
|
3971
3989
|
BigInt(r ?? 0),
|
|
3972
3990
|
n
|
|
@@ -3974,7 +3992,7 @@ class so {
|
|
|
3974
3992
|
);
|
|
3975
3993
|
}
|
|
3976
3994
|
async tryWithNotFound(e, t) {
|
|
3977
|
-
if (!
|
|
3995
|
+
if (!C(e))
|
|
3978
3996
|
throw new Error(`Not live log handle was passed to live log driver, handle: ${e}`);
|
|
3979
3997
|
try {
|
|
3980
3998
|
const r = await t();
|
|
@@ -4018,7 +4036,7 @@ class so {
|
|
|
4018
4036
|
this.scheduledOnNextState = [];
|
|
4019
4037
|
try {
|
|
4020
4038
|
const t = this.getAllLogs();
|
|
4021
|
-
await
|
|
4039
|
+
await oe(
|
|
4022
4040
|
this.opts.nConcurrentGetLogs,
|
|
4023
4041
|
t.map((r) => async () => await r.update())
|
|
4024
4042
|
), e.forEach((r) => r.resolve());
|
|
@@ -4034,12 +4052,12 @@ class so {
|
|
|
4034
4052
|
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
|
|
4035
4053
|
}
|
|
4036
4054
|
}
|
|
4037
|
-
class
|
|
4055
|
+
class me {
|
|
4038
4056
|
constructor(e, t, r, n, o) {
|
|
4039
4057
|
d(this, "logs");
|
|
4040
4058
|
d(this, "error");
|
|
4041
|
-
d(this, "change", new
|
|
4042
|
-
d(this, "counter", new
|
|
4059
|
+
d(this, "change", new $());
|
|
4060
|
+
d(this, "counter", new v());
|
|
4043
4061
|
this.logger = e, this.clientLogs = t, this.rInfo = r, this.lines = n, this.patternToSearch = o;
|
|
4044
4062
|
}
|
|
4045
4063
|
getLog() {
|
|
@@ -4070,14 +4088,14 @@ class fe {
|
|
|
4070
4088
|
return;
|
|
4071
4089
|
}
|
|
4072
4090
|
throw this.logger.error(
|
|
4073
|
-
`Stream log lines for ${
|
|
4091
|
+
`Stream log lines for ${L(this.rInfo.id)} failed, reason: ${e}`
|
|
4074
4092
|
), e;
|
|
4075
4093
|
}
|
|
4076
4094
|
}
|
|
4077
4095
|
}
|
|
4078
|
-
function
|
|
4096
|
+
function J(s, e) {
|
|
4079
4097
|
if (!e.name.startsWith("StreamWorkdir"))
|
|
4080
|
-
throw new
|
|
4098
|
+
throw new he(
|
|
4081
4099
|
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4082
4100
|
);
|
|
4083
4101
|
}
|
|
@@ -4087,12 +4105,12 @@ class io {
|
|
|
4087
4105
|
}
|
|
4088
4106
|
getLastLogs(e, t, r) {
|
|
4089
4107
|
if (r === void 0) return b.make((o) => this.getLastLogs(e, t, o));
|
|
4090
|
-
const n =
|
|
4108
|
+
const n = Q(r, e);
|
|
4091
4109
|
if (n === void 0) {
|
|
4092
4110
|
r.markUnstable("no stream in stream manager");
|
|
4093
4111
|
return;
|
|
4094
4112
|
}
|
|
4095
|
-
if (
|
|
4113
|
+
if (Z(n)) return this.downloadDriver.getLastLogs(n, t, r);
|
|
4096
4114
|
try {
|
|
4097
4115
|
return this.logsStreamDriver.getLastLogs(n, t, r);
|
|
4098
4116
|
} catch (o) {
|
|
@@ -4106,12 +4124,12 @@ class io {
|
|
|
4106
4124
|
getProgressLog(e, t, r) {
|
|
4107
4125
|
if (r === void 0)
|
|
4108
4126
|
return b.make((o) => this.getProgressLog(e, t, o));
|
|
4109
|
-
const n =
|
|
4127
|
+
const n = Q(r, e);
|
|
4110
4128
|
if (n === void 0) {
|
|
4111
4129
|
r.markUnstable("no stream in stream manager");
|
|
4112
4130
|
return;
|
|
4113
4131
|
}
|
|
4114
|
-
if (
|
|
4132
|
+
if (Z(n)) return this.downloadDriver.getProgressLog(n, t, r);
|
|
4115
4133
|
try {
|
|
4116
4134
|
return this.logsStreamDriver.getProgressLog(n, t, r);
|
|
4117
4135
|
} catch (o) {
|
|
@@ -4124,24 +4142,24 @@ class io {
|
|
|
4124
4142
|
}
|
|
4125
4143
|
getLogHandle(e, t) {
|
|
4126
4144
|
if (t === void 0) return b.make((n) => this.getLogHandle(e, n));
|
|
4127
|
-
const r =
|
|
4145
|
+
const r = Q(t, e);
|
|
4128
4146
|
if (r === void 0) {
|
|
4129
4147
|
t.markUnstable("no stream in stream manager");
|
|
4130
4148
|
return;
|
|
4131
4149
|
}
|
|
4132
|
-
return
|
|
4150
|
+
return Z(r) ? this.downloadDriver.getLogHandle(r, t) : this.logsStreamDriver.getLogHandle(r, t);
|
|
4133
4151
|
}
|
|
4134
4152
|
async lastLines(e, t, r, n) {
|
|
4135
|
-
return
|
|
4153
|
+
return C(e) ? await this.logsStreamDriver.lastLines(e, t, r, n) : await this.downloadDriver.lastLines(e, t, r, n);
|
|
4136
4154
|
}
|
|
4137
4155
|
async readText(e, t, r, n) {
|
|
4138
|
-
return
|
|
4156
|
+
return C(e) ? await this.logsStreamDriver.readText(e, t, r, n) : await this.downloadDriver.readText(e, t, r, n);
|
|
4139
4157
|
}
|
|
4140
4158
|
}
|
|
4141
|
-
function
|
|
4159
|
+
function Z(s) {
|
|
4142
4160
|
return !s.type.name.startsWith("StreamWorkdir");
|
|
4143
4161
|
}
|
|
4144
|
-
function
|
|
4162
|
+
function Q(s, e) {
|
|
4145
4163
|
var t;
|
|
4146
4164
|
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4147
4165
|
}
|
|
@@ -4157,11 +4175,11 @@ class ao {
|
|
|
4157
4175
|
/** Writes and removes files to a hard drive and holds a counter for every
|
|
4158
4176
|
* file that should be kept. */
|
|
4159
4177
|
d(this, "cache");
|
|
4160
|
-
this.logger = e, this.saveDir = r, this.opts = n, this.downloadQueue = new
|
|
4178
|
+
this.logger = e, this.saveDir = r, this.opts = n, this.downloadQueue = new ne(this.logger, this.opts.nConcurrentDownloads), this.cache = new Fe(this.opts.cacheSoftSizeBytes), this.downloadHelper = new ve(t);
|
|
4161
4179
|
}
|
|
4162
4180
|
getPath(e, t) {
|
|
4163
4181
|
if (t === void 0) return b.make((o) => this.getPath(e, o));
|
|
4164
|
-
const r =
|
|
4182
|
+
const r = P();
|
|
4165
4183
|
t.addOnDestroy(() => this.releasePath(e, r));
|
|
4166
4184
|
const n = this.getPathNoCtx(e, t.watcher, r);
|
|
4167
4185
|
return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
|
|
@@ -4192,20 +4210,26 @@ class ao {
|
|
|
4192
4210
|
const o = this.cache.removeFile(n.path, t);
|
|
4193
4211
|
await Promise.all(
|
|
4194
4212
|
o.map(async (l) => {
|
|
4195
|
-
await
|
|
4213
|
+
await ee(l.path), this.cache.removeCache(l), this.removeTask(
|
|
4196
4214
|
l,
|
|
4197
|
-
`the task ${
|
|
4215
|
+
`the task ${L(l.info())} was removedfrom cache along with ${L(o.map((i) => i.info()))}`
|
|
4198
4216
|
);
|
|
4199
4217
|
})
|
|
4200
4218
|
);
|
|
4201
4219
|
} else
|
|
4202
|
-
n.counter.dec(t) && this.removeTask(
|
|
4220
|
+
n.counter.dec(t) && this.removeTask(
|
|
4221
|
+
n,
|
|
4222
|
+
`the task ${L(n.info())} was removed from cache`
|
|
4223
|
+
);
|
|
4203
4224
|
}
|
|
4204
4225
|
/** Removes all files from a hard drive. */
|
|
4205
4226
|
async releaseAll() {
|
|
4206
4227
|
this.downloadQueue.stop(), await Promise.all(
|
|
4207
4228
|
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4208
|
-
await
|
|
4229
|
+
await ee(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4230
|
+
t,
|
|
4231
|
+
`the task ${L(t.info())} was released when the driver was closed`
|
|
4232
|
+
);
|
|
4209
4233
|
})
|
|
4210
4234
|
);
|
|
4211
4235
|
}
|
|
@@ -4223,14 +4247,23 @@ class ao {
|
|
|
4223
4247
|
}
|
|
4224
4248
|
class mn {
|
|
4225
4249
|
constructor(e, t, r) {
|
|
4226
|
-
d(this, "counter", new
|
|
4227
|
-
d(this, "change", new
|
|
4250
|
+
d(this, "counter", new v());
|
|
4251
|
+
d(this, "change", new $());
|
|
4228
4252
|
d(this, "signalCtl", new AbortController());
|
|
4229
4253
|
d(this, "error");
|
|
4230
4254
|
d(this, "done", !1);
|
|
4231
4255
|
d(this, "size", 0);
|
|
4232
4256
|
this.logger = e, this.path = t, this.url = r;
|
|
4233
4257
|
}
|
|
4258
|
+
info() {
|
|
4259
|
+
return {
|
|
4260
|
+
url: this.url.toString(),
|
|
4261
|
+
path: this.path,
|
|
4262
|
+
done: this.done,
|
|
4263
|
+
size: this.size,
|
|
4264
|
+
error: this.error
|
|
4265
|
+
};
|
|
4266
|
+
}
|
|
4234
4267
|
attach(e, t) {
|
|
4235
4268
|
this.counter.inc(t), this.done || this.change.attachWatcher(e);
|
|
4236
4269
|
}
|
|
@@ -4239,8 +4272,8 @@ class mn {
|
|
|
4239
4272
|
const r = await this.downloadAndUntar(e, t, this.signalCtl.signal);
|
|
4240
4273
|
this.setDone(r), this.change.markChanged();
|
|
4241
4274
|
} catch (r) {
|
|
4242
|
-
if (r instanceof
|
|
4243
|
-
this.setError(r), this.change.markChanged(), await
|
|
4275
|
+
if (r instanceof we || r instanceof de) {
|
|
4276
|
+
this.setError(r), this.change.markChanged(), await ee(this.path);
|
|
4244
4277
|
return;
|
|
4245
4278
|
}
|
|
4246
4279
|
throw r;
|
|
@@ -4257,12 +4290,12 @@ class mn {
|
|
|
4257
4290
|
}
|
|
4258
4291
|
return await Pe(this.logger, this.path, async (l) => {
|
|
4259
4292
|
await m.mkdir(l);
|
|
4260
|
-
const i =
|
|
4293
|
+
const i = ae.toWeb(ht.extract(l));
|
|
4261
4294
|
await o.pipeTo(i, { signal: r });
|
|
4262
4295
|
}), n.size;
|
|
4263
4296
|
}
|
|
4264
4297
|
getPath() {
|
|
4265
|
-
if (this.done) return { path:
|
|
4298
|
+
if (this.done) return { path: re(this.path) };
|
|
4266
4299
|
if (this.error) return { error: this.error };
|
|
4267
4300
|
}
|
|
4268
4301
|
setDone(e) {
|
|
@@ -4272,10 +4305,10 @@ class mn {
|
|
|
4272
4305
|
this.error = String(e);
|
|
4273
4306
|
}
|
|
4274
4307
|
abort(e) {
|
|
4275
|
-
this.signalCtl.abort(new
|
|
4308
|
+
this.signalCtl.abort(new we(e));
|
|
4276
4309
|
}
|
|
4277
4310
|
}
|
|
4278
|
-
class
|
|
4311
|
+
class we extends Error {
|
|
4279
4312
|
}
|
|
4280
4313
|
async function je(s) {
|
|
4281
4314
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
@@ -4286,10 +4319,10 @@ async function je(s) {
|
|
|
4286
4319
|
})
|
|
4287
4320
|
)).reduce((r, n) => r + n, 0);
|
|
4288
4321
|
}
|
|
4289
|
-
async function
|
|
4322
|
+
async function ee(s) {
|
|
4290
4323
|
await m.rm(s, { recursive: !0, force: !0 });
|
|
4291
4324
|
}
|
|
4292
|
-
function
|
|
4325
|
+
function ye(s, e) {
|
|
4293
4326
|
return `index://index/${encodeURIComponent(JSON.stringify({
|
|
4294
4327
|
storageId: s,
|
|
4295
4328
|
path: e
|
|
@@ -4306,7 +4339,7 @@ function wn(s, e, t, r) {
|
|
|
4306
4339
|
}
|
|
4307
4340
|
function yn(s) {
|
|
4308
4341
|
const e = new URL(s);
|
|
4309
|
-
return
|
|
4342
|
+
return F.parse(
|
|
4310
4343
|
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4311
4344
|
);
|
|
4312
4345
|
}
|
|
@@ -4350,7 +4383,7 @@ function Sn(s) {
|
|
|
4350
4383
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4351
4384
|
const { name: t, resourceId: r } = e.groups;
|
|
4352
4385
|
return {
|
|
4353
|
-
id:
|
|
4386
|
+
id: te(BigInt(r)),
|
|
4354
4387
|
type: Un(t),
|
|
4355
4388
|
name: t,
|
|
4356
4389
|
isRemote: !0
|
|
@@ -4361,7 +4394,7 @@ function Un(s) {
|
|
|
4361
4394
|
}
|
|
4362
4395
|
async function Nn() {
|
|
4363
4396
|
const s = at.homedir();
|
|
4364
|
-
if (
|
|
4397
|
+
if (X.sep == "/")
|
|
4365
4398
|
return [
|
|
4366
4399
|
{
|
|
4367
4400
|
name: "local",
|
|
@@ -4370,7 +4403,7 @@ async function Nn() {
|
|
|
4370
4403
|
}
|
|
4371
4404
|
];
|
|
4372
4405
|
{
|
|
4373
|
-
const t =
|
|
4406
|
+
const t = X.parse(s).root.replaceAll(":\\", "");
|
|
4374
4407
|
try {
|
|
4375
4408
|
return (await pt.promisify(gt)("wmic logicaldisk get name")).stdout.split(`\r
|
|
4376
4409
|
`).filter((o) => o.includes(":")).map((o) => o.trim().replaceAll(":", "")).map((o) => {
|
|
@@ -4443,11 +4476,11 @@ class qe {
|
|
|
4443
4476
|
}
|
|
4444
4477
|
}
|
|
4445
4478
|
async getLocalFileHandle(e) {
|
|
4446
|
-
|
|
4479
|
+
D(e);
|
|
4447
4480
|
for (const r of this.localProjectionsMap.values())
|
|
4448
4481
|
if (e.startsWith(r.localPath)) {
|
|
4449
4482
|
const n = r.localPath === "" ? e : w.relative(r.localPath, e);
|
|
4450
|
-
return
|
|
4483
|
+
return ye(
|
|
4451
4484
|
r.storageId,
|
|
4452
4485
|
n
|
|
4453
4486
|
);
|
|
@@ -4485,10 +4518,10 @@ class qe {
|
|
|
4485
4518
|
type: i.isDir ? "dir" : "file",
|
|
4486
4519
|
name: i.name,
|
|
4487
4520
|
fullPath: i.fullName,
|
|
4488
|
-
handle:
|
|
4521
|
+
handle: ye(r.name, i.fullName)
|
|
4489
4522
|
}))
|
|
4490
4523
|
};
|
|
4491
|
-
w.sep === "/" && t === "" && (t = "/"), r.rootPath === "" &&
|
|
4524
|
+
w.sep === "/" && t === "" && (t = "/"), r.rootPath === "" && D(t);
|
|
4492
4525
|
const n = w.isAbsolute(t) ? t : w.join(r.rootPath, t), o = [];
|
|
4493
4526
|
for await (const l of await m.opendir(n)) {
|
|
4494
4527
|
if (!l.isFile() && !l.isDirectory()) continue;
|
|
@@ -4510,8 +4543,8 @@ class qe {
|
|
|
4510
4543
|
static async init(e, t, r, n, o, l) {
|
|
4511
4544
|
const i = jr(t, e);
|
|
4512
4545
|
l || (l = await Nn());
|
|
4513
|
-
for (const p of l)
|
|
4514
|
-
for (const p of n) p.localPath !== "" &&
|
|
4546
|
+
for (const p of l) D(p.root);
|
|
4547
|
+
for (const p of n) p.localPath !== "" && D(p.localPath);
|
|
4515
4548
|
const c = new Map(l.map((p) => [p.name, p])), a = new Map(n.map((p) => [p.storageId, p]));
|
|
4516
4549
|
if ((/* @__PURE__ */ new Set([...c.keys(), ...a.keys()])).size !== c.size + a.size)
|
|
4517
4550
|
throw new Error(
|
|
@@ -4544,13 +4577,13 @@ export {
|
|
|
4544
4577
|
Hr as ClientLogs,
|
|
4545
4578
|
Dr as ClientLs,
|
|
4546
4579
|
or as ClientProgress,
|
|
4547
|
-
|
|
4580
|
+
zt as ClientUpload,
|
|
4548
4581
|
Nn as DefaultVirtualLocalStorages,
|
|
4549
4582
|
no as DownloadDriver,
|
|
4550
4583
|
ao as DownloadUrlDriver,
|
|
4551
4584
|
ro as ImportFileHandleData,
|
|
4552
4585
|
We as ImportFileHandleIndexData,
|
|
4553
|
-
|
|
4586
|
+
F as ImportFileHandleUploadData,
|
|
4554
4587
|
Xr as IndexResourceSnapshot,
|
|
4555
4588
|
io as LogsDriver,
|
|
4556
4589
|
so as LogsStreamDriver,
|
|
@@ -4565,7 +4598,7 @@ export {
|
|
|
4565
4598
|
oo as UploadDriver,
|
|
4566
4599
|
Qr as UploadResourceSnapshot,
|
|
4567
4600
|
$e as WrongLocalFileUrl,
|
|
4568
|
-
|
|
4601
|
+
he as WrongResourceTypeError,
|
|
4569
4602
|
Yn as createDownloadClient,
|
|
4570
4603
|
Kn as createLogsClient,
|
|
4571
4604
|
jr as createLsFilesClient,
|
|
@@ -4576,6 +4609,6 @@ export {
|
|
|
4576
4609
|
pn as makeBlobImportSnapshot,
|
|
4577
4610
|
br as newLocalStorageIdsToRoot,
|
|
4578
4611
|
fr as parseLocalUrl,
|
|
4579
|
-
|
|
4612
|
+
D as validateAbsolute
|
|
4580
4613
|
};
|
|
4581
4614
|
//# sourceMappingURL=index.mjs.map
|