@milaboratories/pl-drivers 1.5.50 → 1.5.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drivers/upload.d.ts.map +1 -1
- package/dist/drivers/upload_task.d.ts +11 -1
- package/dist/drivers/upload_task.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- 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 +177 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/drivers/download_blob.ts +1 -1
- package/src/drivers/upload.ts +3 -2
- package/src/drivers/upload_task.ts +74 -39
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -5,19 +5,19 @@ import { addRTypeToMetadata as P, bigintToResourceId as he, stringifyWithResourc
|
|
|
5
5
|
import * as m from "node:fs/promises";
|
|
6
6
|
import { request as Ne } from "undici";
|
|
7
7
|
import { ServiceType as _, stackIntercept as T } from "@protobuf-ts/runtime-rpc";
|
|
8
|
-
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as
|
|
8
|
+
import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u, WireType as h, PbLong as D, typeofJsonValue as Be, assertNever as ct } from "@protobuf-ts/runtime";
|
|
9
9
|
import { notEmpty as H, CallersCounter as v, ensureDirExists as ue, fileExists as pe, createPathAtomically as ge, mapGet as Pe, mapEntries as dt, TaskProcessor as j, asyncPool as fe, assertNever as ht } from "@milaboratories/ts-helpers";
|
|
10
10
|
import * as me from "node:fs";
|
|
11
11
|
import ie from "node:fs";
|
|
12
12
|
import * as b from "node:path";
|
|
13
13
|
import L from "node:path";
|
|
14
|
-
import { Readable as we, Writable as
|
|
14
|
+
import { Readable as we, Writable as S, Transform as $e } from "node:stream";
|
|
15
15
|
import { text as ut, buffer as Ce } from "node:stream/consumers";
|
|
16
16
|
import { ChangeSource as N, Computable as w, PollingComputableHooks as _e } from "@milaboratories/computable";
|
|
17
17
|
import { rsSchema as G, treeEntryToResourceInfo as R, isPlTreeEntry as E, makeResourceSnapshot as x, isPlTreeEntryAccessor as Ee } from "@milaboratories/pl-tree";
|
|
18
18
|
import pt from "denque";
|
|
19
|
-
import { randomUUID as
|
|
20
|
-
import * as
|
|
19
|
+
import { randomUUID as U, createHash as gt } from "node:crypto";
|
|
20
|
+
import * as Ue from "node:os";
|
|
21
21
|
import ft from "node:os";
|
|
22
22
|
import * as mt from "node:readline/promises";
|
|
23
23
|
import { z as k } from "zod";
|
|
@@ -71,7 +71,7 @@ class Pt extends g {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
new Pt();
|
|
74
|
-
class
|
|
74
|
+
class Ut extends g {
|
|
75
75
|
constructor() {
|
|
76
76
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Request", [
|
|
77
77
|
{
|
|
@@ -125,7 +125,7 @@ class Dt extends g {
|
|
|
125
125
|
), t;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const
|
|
128
|
+
const Dt = new Ut();
|
|
129
129
|
class Rt extends g {
|
|
130
130
|
constructor() {
|
|
131
131
|
super("MiLaboratories.Controller.Shared.uploadapi.Init.Response", [
|
|
@@ -201,8 +201,8 @@ class Rt extends g {
|
|
|
201
201
|
), t;
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
const
|
|
205
|
-
class
|
|
204
|
+
const St = new Rt();
|
|
205
|
+
class It extends g {
|
|
206
206
|
constructor() {
|
|
207
207
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress", []);
|
|
208
208
|
}
|
|
@@ -222,7 +222,7 @@ class St extends g {
|
|
|
222
222
|
), t;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
new
|
|
225
|
+
new It();
|
|
226
226
|
class vt extends g {
|
|
227
227
|
constructor() {
|
|
228
228
|
super("MiLaboratories.Controller.Shared.uploadapi.UpdateProgress.Request", [
|
|
@@ -716,8 +716,8 @@ const Ht = new Mt(), Q = new _(
|
|
|
716
716
|
{
|
|
717
717
|
name: "Init",
|
|
718
718
|
options: {},
|
|
719
|
-
I:
|
|
720
|
-
O:
|
|
719
|
+
I: Dt,
|
|
720
|
+
O: St
|
|
721
721
|
},
|
|
722
722
|
{
|
|
723
723
|
name: "GetPartURL",
|
|
@@ -952,7 +952,7 @@ class Qt extends g {
|
|
|
952
952
|
* Encode `Duration` to JSON string like "3.000001s".
|
|
953
953
|
*/
|
|
954
954
|
internalJsonWrite(e, t) {
|
|
955
|
-
const o =
|
|
955
|
+
const o = D.from(e.seconds).toNumber();
|
|
956
956
|
if (o > 315576e6 || o < -315576e6)
|
|
957
957
|
throw new Error("Duration value out of range.");
|
|
958
958
|
let n = e.seconds.toString();
|
|
@@ -976,7 +976,7 @@ class Qt extends g {
|
|
|
976
976
|
"Unable to parse Duration from JSON string. Invalid format."
|
|
977
977
|
);
|
|
978
978
|
o || (o = this.create());
|
|
979
|
-
const [, r, a, i] = n, c =
|
|
979
|
+
const [, r, a, i] = n, c = D.from(r + a);
|
|
980
980
|
if (c.toNumber() > 315576e6 || c.toNumber() < -315576e6)
|
|
981
981
|
throw new Error(
|
|
982
982
|
"Unable to parse Duration from JSON string. Value out of range."
|
|
@@ -1153,7 +1153,7 @@ class Kt extends g {
|
|
|
1153
1153
|
), t;
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
|
-
const
|
|
1156
|
+
const I = new Kt();
|
|
1157
1157
|
class Yt extends g {
|
|
1158
1158
|
constructor() {
|
|
1159
1159
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus", []);
|
|
@@ -1237,7 +1237,7 @@ const to = new eo();
|
|
|
1237
1237
|
class oo extends g {
|
|
1238
1238
|
constructor() {
|
|
1239
1239
|
super("MiLaboratories.Controller.Shared.ProgressAPI.GetStatus.Response", [
|
|
1240
|
-
{ no: 1, name: "report", kind: "message", T: () =>
|
|
1240
|
+
{ no: 1, name: "report", kind: "message", T: () => I }
|
|
1241
1241
|
]);
|
|
1242
1242
|
}
|
|
1243
1243
|
create(e) {
|
|
@@ -1255,7 +1255,7 @@ class oo extends g {
|
|
|
1255
1255
|
switch (i) {
|
|
1256
1256
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1257
1257
|
1:
|
|
1258
|
-
r.report =
|
|
1258
|
+
r.report = I.internalBinaryRead(
|
|
1259
1259
|
e,
|
|
1260
1260
|
e.uint32(),
|
|
1261
1261
|
o,
|
|
@@ -1281,7 +1281,7 @@ class oo extends g {
|
|
|
1281
1281
|
return r;
|
|
1282
1282
|
}
|
|
1283
1283
|
internalBinaryWrite(e, t, o) {
|
|
1284
|
-
e.report &&
|
|
1284
|
+
e.report && I.internalBinaryWrite(
|
|
1285
1285
|
e.report,
|
|
1286
1286
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1287
1287
|
o
|
|
@@ -1396,7 +1396,7 @@ class ao extends g {
|
|
|
1396
1396
|
constructor() {
|
|
1397
1397
|
super(
|
|
1398
1398
|
"MiLaboratories.Controller.Shared.ProgressAPI.RealtimeStatus.Response",
|
|
1399
|
-
[{ no: 1, name: "report", kind: "message", T: () =>
|
|
1399
|
+
[{ no: 1, name: "report", kind: "message", T: () => I }]
|
|
1400
1400
|
);
|
|
1401
1401
|
}
|
|
1402
1402
|
create(e) {
|
|
@@ -1414,7 +1414,7 @@ class ao extends g {
|
|
|
1414
1414
|
switch (i) {
|
|
1415
1415
|
case /* MiLaboratories.Controller.Shared.ProgressAPI.Report report */
|
|
1416
1416
|
1:
|
|
1417
|
-
r.report =
|
|
1417
|
+
r.report = I.internalBinaryRead(
|
|
1418
1418
|
e,
|
|
1419
1419
|
e.uint32(),
|
|
1420
1420
|
o,
|
|
@@ -1440,7 +1440,7 @@ class ao extends g {
|
|
|
1440
1440
|
return r;
|
|
1441
1441
|
}
|
|
1442
1442
|
internalBinaryWrite(e, t, o) {
|
|
1443
|
-
e.report &&
|
|
1443
|
+
e.report && I.internalBinaryWrite(
|
|
1444
1444
|
e.report,
|
|
1445
1445
|
t.tag(1, h.LengthDelimited).fork(),
|
|
1446
1446
|
o
|
|
@@ -1868,7 +1868,7 @@ class ko {
|
|
|
1868
1868
|
}
|
|
1869
1869
|
async downloadBlob(e, t, o) {
|
|
1870
1870
|
const { downloadUrl: n, headers: r } = await this.grpcGetDownloadUrl(e, t, o);
|
|
1871
|
-
return this.logger.info(`download blob from url ${n}`),
|
|
1871
|
+
return this.logger.info(`download blob from url ${n}`), Do(n) ? await this.readLocalFile(n) : await this.remoteFileDownloader.download(n, We(r), o);
|
|
1872
1872
|
}
|
|
1873
1873
|
async readLocalFile(e) {
|
|
1874
1874
|
const { storageId: t, relativePath: o } = Lo(e), n = Po(t, this.localStorageIdsToRoot, o);
|
|
@@ -1899,9 +1899,9 @@ function Po(s, e, t) {
|
|
|
1899
1899
|
if (o === void 0) throw new be(`Unknown storage location: ${s}`);
|
|
1900
1900
|
return o === "" ? t : b.join(o, t);
|
|
1901
1901
|
}
|
|
1902
|
-
const
|
|
1903
|
-
function
|
|
1904
|
-
return s.startsWith(
|
|
1902
|
+
const Uo = "storage://";
|
|
1903
|
+
function Do(s) {
|
|
1904
|
+
return s.startsWith(Uo);
|
|
1905
1905
|
}
|
|
1906
1906
|
class ye extends Error {
|
|
1907
1907
|
}
|
|
@@ -1913,7 +1913,7 @@ function Ro(s) {
|
|
|
1913
1913
|
t.localPath !== "" && C(t.localPath), e.set(t.storageId, t.localPath);
|
|
1914
1914
|
return e;
|
|
1915
1915
|
}
|
|
1916
|
-
class
|
|
1916
|
+
class So extends g {
|
|
1917
1917
|
constructor() {
|
|
1918
1918
|
super("google.protobuf.Timestamp", [
|
|
1919
1919
|
{
|
|
@@ -1938,14 +1938,14 @@ class Io extends g {
|
|
|
1938
1938
|
*/
|
|
1939
1939
|
now() {
|
|
1940
1940
|
const e = this.create(), t = Date.now();
|
|
1941
|
-
return e.seconds =
|
|
1941
|
+
return e.seconds = D.from(Math.floor(t / 1e3)).toBigInt(), e.nanos = t % 1e3 * 1e6, e;
|
|
1942
1942
|
}
|
|
1943
1943
|
/**
|
|
1944
1944
|
* Converts a `Timestamp` to a JavaScript Date.
|
|
1945
1945
|
*/
|
|
1946
1946
|
toDate(e) {
|
|
1947
1947
|
return new Date(
|
|
1948
|
-
|
|
1948
|
+
D.from(e.seconds).toNumber() * 1e3 + Math.ceil(e.nanos / 1e6)
|
|
1949
1949
|
);
|
|
1950
1950
|
}
|
|
1951
1951
|
/**
|
|
@@ -1953,14 +1953,14 @@ class Io extends g {
|
|
|
1953
1953
|
*/
|
|
1954
1954
|
fromDate(e) {
|
|
1955
1955
|
const t = this.create(), o = e.getTime();
|
|
1956
|
-
return t.seconds =
|
|
1956
|
+
return t.seconds = D.from(Math.floor(o / 1e3)).toBigInt(), t.nanos = o % 1e3 * 1e6, t;
|
|
1957
1957
|
}
|
|
1958
1958
|
/**
|
|
1959
1959
|
* In JSON format, the `Timestamp` type is encoded as a string
|
|
1960
1960
|
* in the RFC 3339 format.
|
|
1961
1961
|
*/
|
|
1962
1962
|
internalJsonWrite(e, t) {
|
|
1963
|
-
const o =
|
|
1963
|
+
const o = D.from(e.seconds).toNumber() * 1e3;
|
|
1964
1964
|
if (o < Date.parse("0001-01-01T00:00:00Z") || o > Date.parse("9999-12-31T23:59:59Z"))
|
|
1965
1965
|
throw new Error(
|
|
1966
1966
|
"Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
@@ -1999,7 +1999,7 @@ class Io extends g {
|
|
|
1999
1999
|
throw new globalThis.Error(
|
|
2000
2000
|
"Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
|
|
2001
2001
|
);
|
|
2002
|
-
return o || (o = this.create()), o.seconds =
|
|
2002
|
+
return o || (o = this.create()), o.seconds = D.from(r / 1e3).toBigInt(), o.nanos = 0, n[7] && (o.nanos = parseInt("1" + n[7] + "0".repeat(9 - n[7].length)) - 1e9), o;
|
|
2003
2003
|
}
|
|
2004
2004
|
create(e) {
|
|
2005
2005
|
const t = globalThis.Object.create(this.messagePrototype);
|
|
@@ -2046,8 +2046,8 @@ class Io extends g {
|
|
|
2046
2046
|
), t;
|
|
2047
2047
|
}
|
|
2048
2048
|
}
|
|
2049
|
-
const ee = new
|
|
2050
|
-
class
|
|
2049
|
+
const ee = new So();
|
|
2050
|
+
class Io extends g {
|
|
2051
2051
|
constructor() {
|
|
2052
2052
|
super("MiLaboratories.Controller.Shared.LsAPI", []);
|
|
2053
2053
|
}
|
|
@@ -2067,7 +2067,7 @@ class So extends g {
|
|
|
2067
2067
|
), t;
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
new
|
|
2070
|
+
new Io();
|
|
2071
2071
|
class vo extends g {
|
|
2072
2072
|
constructor() {
|
|
2073
2073
|
super("MiLaboratories.Controller.Shared.LsAPI.ListItem", [
|
|
@@ -3145,25 +3145,25 @@ class Qo {
|
|
|
3145
3145
|
)).response;
|
|
3146
3146
|
}
|
|
3147
3147
|
}
|
|
3148
|
-
function
|
|
3148
|
+
function Tr(s, e, t) {
|
|
3149
3149
|
return e.getDriver({
|
|
3150
3150
|
name: "DownloadBlob",
|
|
3151
3151
|
init: (o, n, r) => new ko(n, r, s, t)
|
|
3152
3152
|
});
|
|
3153
3153
|
}
|
|
3154
|
-
function
|
|
3154
|
+
function kr(s, e) {
|
|
3155
3155
|
return s.getDriver({
|
|
3156
3156
|
name: "StreamLogs",
|
|
3157
3157
|
init: (t, o, n) => new Qo(o, n, e)
|
|
3158
3158
|
});
|
|
3159
3159
|
}
|
|
3160
|
-
function
|
|
3160
|
+
function Lr(s, e) {
|
|
3161
3161
|
return s.getDriver({
|
|
3162
3162
|
name: "UploadProgress",
|
|
3163
3163
|
init: (t, o, n) => new ho(o, n, s, e)
|
|
3164
3164
|
});
|
|
3165
3165
|
}
|
|
3166
|
-
function
|
|
3166
|
+
function Pr(s, e) {
|
|
3167
3167
|
return s.getDriver({
|
|
3168
3168
|
name: "UploadBlob",
|
|
3169
3169
|
init: (t, o, n) => new Gt(o, n, s, e)
|
|
@@ -3212,7 +3212,7 @@ class Ko {
|
|
|
3212
3212
|
return this.logger.info(`a blob was already downloaded: ${this.path}`), (await m.stat(this.path)).size;
|
|
3213
3213
|
const { content: e, size: t } = await this.clientDownload.downloadBlob(this.rInfo);
|
|
3214
3214
|
return await ge(this.logger, this.path, async (o) => {
|
|
3215
|
-
const n =
|
|
3215
|
+
const n = S.toWeb(ie.createWriteStream(o, { flags: "wx" }));
|
|
3216
3216
|
await e.pipeTo(n);
|
|
3217
3217
|
}), t;
|
|
3218
3218
|
}
|
|
@@ -3322,7 +3322,7 @@ const q = k.object({
|
|
|
3322
3322
|
storageId: k.string(),
|
|
3323
3323
|
/** Path inside storage */
|
|
3324
3324
|
path: k.string()
|
|
3325
|
-
}),
|
|
3325
|
+
}), Ur = k.union([
|
|
3326
3326
|
q,
|
|
3327
3327
|
Ve
|
|
3328
3328
|
]), nn = G({
|
|
@@ -3396,7 +3396,7 @@ class dn {
|
|
|
3396
3396
|
})());
|
|
3397
3397
|
}
|
|
3398
3398
|
}
|
|
3399
|
-
class
|
|
3399
|
+
class Dr {
|
|
3400
3400
|
constructor(e, t, o, n, r, a) {
|
|
3401
3401
|
/** Represents a Resource Id to the path of a blob as a map. */
|
|
3402
3402
|
d(this, "idToDownload", /* @__PURE__ */ new Map());
|
|
@@ -3413,7 +3413,7 @@ class Pr {
|
|
|
3413
3413
|
}
|
|
3414
3414
|
getDownloadedBlob(e, t) {
|
|
3415
3415
|
if (t === void 0) return w.make((a) => this.getDownloadedBlob(e, a));
|
|
3416
|
-
const o = R(e, t), n =
|
|
3416
|
+
const o = R(e, t), n = U();
|
|
3417
3417
|
t.addOnDestroy(() => this.releaseBlob(o.id, n));
|
|
3418
3418
|
const r = this.getDownloadedBlobNoCtx(t.watcher, o, n);
|
|
3419
3419
|
return r == null && t.markUnstable("download blob is still undefined"), r;
|
|
@@ -3452,7 +3452,7 @@ class Pr {
|
|
|
3452
3452
|
}
|
|
3453
3453
|
getOnDemandBlob(e, t) {
|
|
3454
3454
|
if (t === void 0) return w.make((a) => this.getOnDemandBlob(e, a));
|
|
3455
|
-
const o = E(e) ? x(e, tn, t) : e, n =
|
|
3455
|
+
const o = E(e) ? x(e, tn, t) : e, n = U();
|
|
3456
3456
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(o.id, n)), this.getOnDemandBlobNoCtx(o, n);
|
|
3457
3457
|
}
|
|
3458
3458
|
getOnDemandBlobNoCtx(e, t) {
|
|
@@ -3489,7 +3489,7 @@ class Pr {
|
|
|
3489
3489
|
}
|
|
3490
3490
|
getLastLogs(e, t, o) {
|
|
3491
3491
|
if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
|
|
3492
|
-
const n = R(e, o), r =
|
|
3492
|
+
const n = R(e, o), r = U();
|
|
3493
3493
|
o.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3494
3494
|
const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
|
|
3495
3495
|
return a == null && o.markUnstable("either a file was not downloaded or logs was not read"), a;
|
|
@@ -3501,7 +3501,7 @@ class Pr {
|
|
|
3501
3501
|
const { path: a } = re(r.handle, this.signer);
|
|
3502
3502
|
let i = this.idToLastLines.get(t.id);
|
|
3503
3503
|
if (i == null) {
|
|
3504
|
-
const l = new
|
|
3504
|
+
const l = new De(a, o);
|
|
3505
3505
|
this.idToLastLines.set(t.id, l), i = l;
|
|
3506
3506
|
}
|
|
3507
3507
|
const c = i.getOrSchedule(e);
|
|
@@ -3511,7 +3511,7 @@ class Pr {
|
|
|
3511
3511
|
getProgressLog(e, t, o) {
|
|
3512
3512
|
if (o == null)
|
|
3513
3513
|
return w.make((i) => this.getProgressLog(e, t, i));
|
|
3514
|
-
const n = R(e, o), r =
|
|
3514
|
+
const n = R(e, o), r = U();
|
|
3515
3515
|
o.addOnDestroy(() => this.releaseBlob(n.id, r));
|
|
3516
3516
|
const a = this.getProgressLogNoCtx(
|
|
3517
3517
|
o.watcher,
|
|
@@ -3528,7 +3528,7 @@ class Pr {
|
|
|
3528
3528
|
const { path: a } = re(r.handle, this.signer);
|
|
3529
3529
|
let i = this.idToProgressLog.get(t.id);
|
|
3530
3530
|
if (i == null) {
|
|
3531
|
-
const l = new
|
|
3531
|
+
const l = new De(a, 1, o);
|
|
3532
3532
|
this.idToProgressLog.set(t.id, l), i = l;
|
|
3533
3533
|
}
|
|
3534
3534
|
const c = i.getOrSchedule(e);
|
|
@@ -3624,7 +3624,7 @@ class hn {
|
|
|
3624
3624
|
return this.counter.dec(e);
|
|
3625
3625
|
}
|
|
3626
3626
|
}
|
|
3627
|
-
class
|
|
3627
|
+
class De {
|
|
3628
3628
|
constructor(e, t, o) {
|
|
3629
3629
|
d(this, "updater");
|
|
3630
3630
|
d(this, "log");
|
|
@@ -3652,13 +3652,13 @@ class Ue {
|
|
|
3652
3652
|
}
|
|
3653
3653
|
}
|
|
3654
3654
|
function un(s, e, t) {
|
|
3655
|
-
const o = me.createReadStream(s), n = new
|
|
3655
|
+
const o = me.createReadStream(s), n = new S();
|
|
3656
3656
|
return new Promise((r, a) => {
|
|
3657
3657
|
const i = mt.createInterface(o, n), c = new pt();
|
|
3658
3658
|
i.on("line", function(l) {
|
|
3659
3659
|
t != null && !l.includes(t) || (c.push(l), c.length > e && c.shift());
|
|
3660
3660
|
}), i.on("error", a), i.on("close", function() {
|
|
3661
|
-
r(c.toArray().join(
|
|
3661
|
+
r(c.toArray().join(Ue.EOL) + Ue.EOL);
|
|
3662
3662
|
});
|
|
3663
3663
|
});
|
|
3664
3664
|
}
|
|
@@ -3747,17 +3747,17 @@ class Tn {
|
|
|
3747
3747
|
switch (this.state.tempPath = n, this.state.archiveFormat = this.format, this.format) {
|
|
3748
3748
|
case "tar":
|
|
3749
3749
|
await m.mkdir(n);
|
|
3750
|
-
const r =
|
|
3750
|
+
const r = S.toWeb(ae.extract(n));
|
|
3751
3751
|
await t.pipeTo(r, { signal: e });
|
|
3752
3752
|
return;
|
|
3753
3753
|
case "tgz":
|
|
3754
3754
|
await m.mkdir(n);
|
|
3755
|
-
const a = $e.toWeb(Oe.createGunzip()), i =
|
|
3755
|
+
const a = $e.toWeb(Oe.createGunzip()), i = S.toWeb(ae.extract(n));
|
|
3756
3756
|
await t.pipeThrough(a, { signal: e }).pipeTo(i, { signal: e });
|
|
3757
3757
|
return;
|
|
3758
3758
|
case "zip":
|
|
3759
3759
|
this.state.zipPath = this.path + ".zip";
|
|
3760
|
-
const c =
|
|
3760
|
+
const c = S.toWeb(ie.createWriteStream(this.state.zipPath));
|
|
3761
3761
|
await t.pipeTo(c, { signal: e }), this.state.zipPathCreated = !0, await wt(this.state.zipPath, n, {
|
|
3762
3762
|
filter: (l) => !l.path.endsWith("/")
|
|
3763
3763
|
}), this.state.zipDecompressed = !0, await ie.promises.rm(this.state.zipPath), this.state.zipPathDeleted = !0;
|
|
@@ -3801,7 +3801,7 @@ function kn(s) {
|
|
|
3801
3801
|
function O(s, e) {
|
|
3802
3802
|
return `id:${String(BigInt(s))}-${e}`;
|
|
3803
3803
|
}
|
|
3804
|
-
class
|
|
3804
|
+
class Sr {
|
|
3805
3805
|
constructor(e, t, o, n, r = {
|
|
3806
3806
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
3807
3807
|
nConcurrentDownloads: 50
|
|
@@ -3839,7 +3839,7 @@ class Ur {
|
|
|
3839
3839
|
extractArchiveAndGetURL(e, t, o) {
|
|
3840
3840
|
if (o === void 0)
|
|
3841
3841
|
return w.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
3842
|
-
const n = E(e) ? fn(e, o) : e, r =
|
|
3842
|
+
const n = E(e) ? fn(e, o) : e, r = U();
|
|
3843
3843
|
o.addOnDestroy(() => this.releasePath(n.id, t, r));
|
|
3844
3844
|
const a = this.extractArchiveAndGetURLNoCtx(n, t, o.watcher, r);
|
|
3845
3845
|
if ((a == null ? void 0 : a.url) === void 0 && o.markUnstable(
|
|
@@ -3931,54 +3931,49 @@ class Ln {
|
|
|
3931
3931
|
* At this case, the task will show progress == 1.0. */
|
|
3932
3932
|
d(this, "alreadyExisted", !1);
|
|
3933
3933
|
this.logger = e, this.clientBlob = t, this.clientProgress = o, this.maxNConcurrentPartsUpload = n, this.res = a, this.nMaxUploads = this.maxNConcurrentPartsUpload;
|
|
3934
|
-
const { uploadData: i, progress: c } =
|
|
3934
|
+
const { uploadData: i, progress: c } = Un(a, r);
|
|
3935
3935
|
this.uploadData = i, this.progress = c;
|
|
3936
3936
|
}
|
|
3937
3937
|
getProgress(e, t) {
|
|
3938
3938
|
if (this.incCounter(e, t), this.failed)
|
|
3939
3939
|
throw this.logger.error(`Uploading terminally failed: ${this.progress.lastError}`), new Error(this.progress.lastError);
|
|
3940
|
-
return
|
|
3940
|
+
return Rn(this.progress);
|
|
3941
3941
|
}
|
|
3942
3942
|
shouldScheduleUpload() {
|
|
3943
|
-
return this.progress
|
|
3943
|
+
return Dn(this.progress);
|
|
3944
3944
|
}
|
|
3945
3945
|
/** Uploads a blob if it's not BlobIndex. */
|
|
3946
3946
|
async uploadBlobTask() {
|
|
3947
|
-
yt(ce(this.res), "the upload operation can be done only for BlobUploads");
|
|
3948
|
-
const e = 1e4;
|
|
3949
3947
|
try {
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
this.
|
|
3958
|
-
this.
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
if (
|
|
3965
|
-
|
|
3966
|
-
} catch (t) {
|
|
3967
|
-
if (this.setRetriableError(t), Re(t)) {
|
|
3968
|
-
this.logger.warn(`resource was deleted while uploading a blob: ${t}`), this.change.markChanged(), this.setDone(!0);
|
|
3948
|
+
await Pn(
|
|
3949
|
+
this.logger,
|
|
3950
|
+
this.clientBlob,
|
|
3951
|
+
this.res,
|
|
3952
|
+
this.uploadData,
|
|
3953
|
+
this.isComputableDone.bind(this),
|
|
3954
|
+
{
|
|
3955
|
+
nPartsWithThisUploadSpeed: this.nPartsWithThisUploadSpeed,
|
|
3956
|
+
nPartsToIncreaseUpload: this.nPartsToIncreaseUpload,
|
|
3957
|
+
currentSpeed: this.nMaxUploads,
|
|
3958
|
+
maxSpeed: this.maxNConcurrentPartsUpload
|
|
3959
|
+
}
|
|
3960
|
+
), this.change.markChanged();
|
|
3961
|
+
} catch (e) {
|
|
3962
|
+
if (this.setRetriableError(e), Re(e)) {
|
|
3963
|
+
this.logger.warn(`resource was deleted while uploading a blob: ${e}`), this.change.markChanged(), this.setDone(!0);
|
|
3969
3964
|
return;
|
|
3970
3965
|
}
|
|
3971
|
-
if (this.logger.error(`error while uploading a blob: ${
|
|
3972
|
-
this.setTerminalError(
|
|
3966
|
+
if (this.logger.error(`error while uploading a blob: ${e}`), this.change.markChanged(), Ye(e)) {
|
|
3967
|
+
this.setTerminalError(e);
|
|
3973
3968
|
return;
|
|
3974
3969
|
}
|
|
3975
|
-
throw
|
|
3970
|
+
throw Bn(e) && (this.nMaxUploads = Cn(this.logger, this.nMaxUploads, 1)), e;
|
|
3976
3971
|
}
|
|
3977
3972
|
}
|
|
3978
3973
|
async updateStatus() {
|
|
3979
3974
|
var e;
|
|
3980
3975
|
try {
|
|
3981
|
-
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n =
|
|
3976
|
+
const t = await this.clientProgress.getStatus(this.res, { timeout: 1e4 }), o = this.progress.status, n = Nn(this.alreadyExisted, vn(t));
|
|
3982
3977
|
this.progress.status = n, this.setDone(t.done), (t.done || this.progress.status.progress != (o == null ? void 0 : o.progress)) && this.change.markChanged();
|
|
3983
3978
|
} catch (t) {
|
|
3984
3979
|
if (this.setRetriableError(t), t.name == "RpcError" && t.code == "DEADLINE_EXCEEDED" || (e = t == null ? void 0 : t.message) != null && e.includes("DEADLINE_EXCEEDED")) {
|
|
@@ -4003,7 +3998,7 @@ class Ln {
|
|
|
4003
3998
|
this.progress.lastError = String(e), this.progress.done = !1, this.failed = !0;
|
|
4004
3999
|
}
|
|
4005
4000
|
setDoneIfOutputSet(e) {
|
|
4006
|
-
|
|
4001
|
+
Sn(e) && (this.setDone(!0), this.alreadyExisted = !0);
|
|
4007
4002
|
}
|
|
4008
4003
|
setDone(e) {
|
|
4009
4004
|
this.progress.done = e, e && (this.progress.lastError = void 0);
|
|
@@ -4018,9 +4013,28 @@ class Ln {
|
|
|
4018
4013
|
return this.counter.isZero();
|
|
4019
4014
|
}
|
|
4020
4015
|
}
|
|
4021
|
-
function Pn(s, e) {
|
|
4016
|
+
async function Pn(s, e, t, o, n, r) {
|
|
4017
|
+
yt(ce(t), "the upload operation can be done only for BlobUploads");
|
|
4018
|
+
const a = 1e4;
|
|
4019
|
+
if (n()) return;
|
|
4020
|
+
const i = await e.initUpload(t, { timeout: a });
|
|
4021
|
+
s.info(
|
|
4022
|
+
`started to upload blob ${t.id}, parts overall: ${i.overall}, parts remained: ${i.toUpload.length}, number of concurrent uploads: ${r.currentSpeed}`
|
|
4023
|
+
);
|
|
4024
|
+
const c = (l) => async (p) => {
|
|
4025
|
+
n() || (await e.partUpload(
|
|
4026
|
+
t,
|
|
4027
|
+
o.localPath,
|
|
4028
|
+
BigInt(o.modificationTime),
|
|
4029
|
+
l,
|
|
4030
|
+
{ timeout: a }
|
|
4031
|
+
), 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)));
|
|
4032
|
+
};
|
|
4033
|
+
await fe(r.currentSpeed, i.toUpload.map(c)), !n() && (await e.finalize(t, { timeout: a }), s.info(`uploading of resource ${t.id} finished.`));
|
|
4034
|
+
}
|
|
4035
|
+
function Un(s, e) {
|
|
4022
4036
|
let t, o;
|
|
4023
|
-
return ce(s) && (o = q.parse(s.data), t =
|
|
4037
|
+
return ce(s) && (o = q.parse(s.data), t = In(e, o.localPath, o.pathSignature)), {
|
|
4024
4038
|
uploadData: o,
|
|
4025
4039
|
progress: {
|
|
4026
4040
|
done: !1,
|
|
@@ -4032,29 +4046,32 @@ function Pn(s, e) {
|
|
|
4032
4046
|
};
|
|
4033
4047
|
}
|
|
4034
4048
|
function Dn(s) {
|
|
4049
|
+
return s.isUpload && (s.isUploadSignMatch ?? !1);
|
|
4050
|
+
}
|
|
4051
|
+
function Rn(s) {
|
|
4035
4052
|
return s.done, s.isUpload, s.isUploadSignMatch, s.lastError, s.status && (s.status.progress, s.status.bytesProcessed, s.status.bytesTotal), s;
|
|
4036
4053
|
}
|
|
4037
|
-
function
|
|
4054
|
+
function Sn(s) {
|
|
4038
4055
|
return "blob" in s.fields ? s.fields.blob !== void 0 : s.fields.incarnation !== void 0;
|
|
4039
4056
|
}
|
|
4040
4057
|
function ce(s) {
|
|
4041
4058
|
return s.type.name.startsWith("BlobUpload");
|
|
4042
4059
|
}
|
|
4043
|
-
function
|
|
4060
|
+
function In(s, e, t) {
|
|
4044
4061
|
try {
|
|
4045
4062
|
return s.verify(e, t), !0;
|
|
4046
4063
|
} catch {
|
|
4047
4064
|
return !1;
|
|
4048
4065
|
}
|
|
4049
4066
|
}
|
|
4050
|
-
function
|
|
4067
|
+
function vn(s) {
|
|
4051
4068
|
return {
|
|
4052
4069
|
progress: s.progress ?? 0,
|
|
4053
4070
|
bytesProcessed: Number(s.bytesProcessed),
|
|
4054
4071
|
bytesTotal: Number(s.bytesTotal)
|
|
4055
4072
|
};
|
|
4056
4073
|
}
|
|
4057
|
-
function
|
|
4074
|
+
function Nn(s, e) {
|
|
4058
4075
|
return s && e.bytesTotal != 0 && e.bytesProcessed == 0 ? {
|
|
4059
4076
|
progress: 1,
|
|
4060
4077
|
bytesProcessed: Number(e.bytesTotal),
|
|
@@ -4067,22 +4084,22 @@ function Re(s) {
|
|
|
4067
4084
|
function Ye(s) {
|
|
4068
4085
|
return s instanceof ze || s instanceof xe || s instanceof Me;
|
|
4069
4086
|
}
|
|
4070
|
-
function
|
|
4087
|
+
function Bn(s) {
|
|
4071
4088
|
return s == null ? void 0 : s.message.includes("UND_ERR_HEADERS_TIMEOUT");
|
|
4072
4089
|
}
|
|
4073
|
-
function
|
|
4090
|
+
function $n(s, e, t) {
|
|
4074
4091
|
const o = Math.min(e + 2, t);
|
|
4075
4092
|
return o != e && s.info(`uploadTask.increaseConcurrency: increased from ${e} to ${o}`), o;
|
|
4076
4093
|
}
|
|
4077
|
-
function
|
|
4094
|
+
function Cn(s, e, t) {
|
|
4078
4095
|
const o = Math.max(Math.round(e / 2), t);
|
|
4079
4096
|
return o != e && s.info(`uploadTask.decreaseConcurrency: decreased from ${e} to ${o}`), o;
|
|
4080
4097
|
}
|
|
4081
|
-
function
|
|
4098
|
+
function _n(s, e) {
|
|
4082
4099
|
const t = E(s) ? e.accessor(s).node() : Ee(s) ? s.node() : s;
|
|
4083
4100
|
return t.resourceType.name.startsWith("BlobUpload") ? x(t, nn) : x(t, rn);
|
|
4084
4101
|
}
|
|
4085
|
-
class
|
|
4102
|
+
class Ir {
|
|
4086
4103
|
constructor(e, t, o, n, r = {
|
|
4087
4104
|
nConcurrentPartUploads: 10,
|
|
4088
4105
|
nConcurrentGetProgresses: 10,
|
|
@@ -4114,11 +4131,11 @@ class Rr {
|
|
|
4114
4131
|
}
|
|
4115
4132
|
getProgressId(e, t) {
|
|
4116
4133
|
if (t == null) return w.make((a) => this.getProgressId(e, a));
|
|
4117
|
-
const o = E(e) ?
|
|
4134
|
+
const o = E(e) ? _n(e, t) : e, n = U();
|
|
4118
4135
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(o.id, n)), this.getProgressIdNoCtx(t.watcher, o, n);
|
|
4119
4136
|
}
|
|
4120
4137
|
getProgressIdNoCtx(e, t, o) {
|
|
4121
|
-
|
|
4138
|
+
On("getProgressId", t.type);
|
|
4122
4139
|
const n = this.idToProgress.get(t.id);
|
|
4123
4140
|
if (n != null)
|
|
4124
4141
|
return n.setDoneIfOutputSet(t), n.getProgress(e, o);
|
|
@@ -4174,20 +4191,20 @@ class Rr {
|
|
|
4174
4191
|
this.currentLoop = void 0;
|
|
4175
4192
|
}
|
|
4176
4193
|
getAllNotDoneProgresses() {
|
|
4177
|
-
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !
|
|
4194
|
+
return Array.from(this.idToProgress.entries()).filter(([e, t]) => !En(t.progress)).map(([e, t]) => t);
|
|
4178
4195
|
}
|
|
4179
4196
|
}
|
|
4180
|
-
function
|
|
4197
|
+
function En(s) {
|
|
4181
4198
|
var e;
|
|
4182
4199
|
return s.done && (((e = s.status) == null ? void 0 : e.progress) ?? 0) >= 1;
|
|
4183
4200
|
}
|
|
4184
|
-
function
|
|
4201
|
+
function On(s, e) {
|
|
4185
4202
|
if (!e.name.startsWith("BlobUpload") && !e.name.startsWith("BlobIndex"))
|
|
4186
4203
|
throw new Le(
|
|
4187
4204
|
`${s}: wrong resource type: ${e.name}, expected: a resource of either type 'BlobUpload' or 'BlobIndex'.`
|
|
4188
4205
|
);
|
|
4189
4206
|
}
|
|
4190
|
-
class
|
|
4207
|
+
class vr {
|
|
4191
4208
|
constructor(e, t, o = {
|
|
4192
4209
|
nConcurrentGetLogs: 10,
|
|
4193
4210
|
pollingInterval: 1e3,
|
|
@@ -4213,7 +4230,7 @@ class Ir {
|
|
|
4213
4230
|
}
|
|
4214
4231
|
getLastLogs(e, t, o) {
|
|
4215
4232
|
if (o == null) return w.make((i) => this.getLastLogs(e, t, i));
|
|
4216
|
-
const n = R(e, o), r =
|
|
4233
|
+
const n = R(e, o), r = U();
|
|
4217
4234
|
o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseLastLogs(n.id, r));
|
|
4218
4235
|
const a = this.getLastLogsNoCtx(o.watcher, n, t, r);
|
|
4219
4236
|
return o.markUnstable(
|
|
@@ -4224,7 +4241,7 @@ class Ir {
|
|
|
4224
4241
|
se("getLastLogs", t.type);
|
|
4225
4242
|
let r = this.idToLastLines.get(t.id);
|
|
4226
4243
|
if (r == null) {
|
|
4227
|
-
const i = new
|
|
4244
|
+
const i = new Se(this.logger, this.clientLogs, t, o);
|
|
4228
4245
|
this.idToLastLines.set(t.id, i), r = i;
|
|
4229
4246
|
}
|
|
4230
4247
|
r.attach(e, n);
|
|
@@ -4235,7 +4252,7 @@ class Ir {
|
|
|
4235
4252
|
getProgressLog(e, t, o) {
|
|
4236
4253
|
if (o == null)
|
|
4237
4254
|
return w.make((i) => this.getProgressLog(e, t, i));
|
|
4238
|
-
const n = R(e, o), r =
|
|
4255
|
+
const n = R(e, o), r = U();
|
|
4239
4256
|
o.attacheHooks(this.hooks), o.addOnDestroy(() => this.releaseProgressLog(n.id, r));
|
|
4240
4257
|
const a = this.getProgressLogNoCtx(o.watcher, n, t, r);
|
|
4241
4258
|
return o.markUnstable(
|
|
@@ -4246,7 +4263,7 @@ class Ir {
|
|
|
4246
4263
|
se("getProgressLog", t.type);
|
|
4247
4264
|
let r = this.idToProgressLog.get(t.id);
|
|
4248
4265
|
if (r == null) {
|
|
4249
|
-
const i = new
|
|
4266
|
+
const i = new Se(this.logger, this.clientLogs, t, 1, o);
|
|
4250
4267
|
this.idToProgressLog.set(t.id, i), r = i;
|
|
4251
4268
|
}
|
|
4252
4269
|
r.attach(e, n);
|
|
@@ -4345,7 +4362,7 @@ class Ir {
|
|
|
4345
4362
|
return Array.from(this.idToLastLines.entries()).concat(Array.from(this.idToProgressLog.entries())).map(([e, t]) => t);
|
|
4346
4363
|
}
|
|
4347
4364
|
}
|
|
4348
|
-
class
|
|
4365
|
+
class Se {
|
|
4349
4366
|
constructor(e, t, o, n, r) {
|
|
4350
4367
|
d(this, "logs");
|
|
4351
4368
|
d(this, "error");
|
|
@@ -4392,7 +4409,7 @@ function se(s, e) {
|
|
|
4392
4409
|
`${s}: wrong resource type: ${e.name}, expected: a resource of type 'StreamWorkdir'.`
|
|
4393
4410
|
);
|
|
4394
4411
|
}
|
|
4395
|
-
class
|
|
4412
|
+
class Nr {
|
|
4396
4413
|
constructor(e, t, o) {
|
|
4397
4414
|
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = o;
|
|
4398
4415
|
}
|
|
@@ -4482,7 +4499,7 @@ function W(s, e) {
|
|
|
4482
4499
|
var t;
|
|
4483
4500
|
return (t = s.accessor(e).node().traverse("stream")) == null ? void 0 : t.resourceInfo;
|
|
4484
4501
|
}
|
|
4485
|
-
class
|
|
4502
|
+
class Br {
|
|
4486
4503
|
constructor(e, t, o, n = {
|
|
4487
4504
|
cacheSoftSizeBytes: 50 * 1024 * 1024,
|
|
4488
4505
|
withGunzip: !0,
|
|
@@ -4498,7 +4515,7 @@ class vr {
|
|
|
4498
4515
|
}
|
|
4499
4516
|
getPath(e, t) {
|
|
4500
4517
|
if (t === void 0) return w.make((r) => this.getPath(e, r));
|
|
4501
|
-
const o =
|
|
4518
|
+
const o = U();
|
|
4502
4519
|
t.addOnDestroy(() => this.releasePath(e, o));
|
|
4503
4520
|
const n = this.getPathNoCtx(e, t.watcher, o);
|
|
4504
4521
|
return (n == null ? void 0 : n.path) === void 0 && t.markUnstable(
|
|
@@ -4553,7 +4570,7 @@ class vr {
|
|
|
4553
4570
|
);
|
|
4554
4571
|
}
|
|
4555
4572
|
setNewTask(e, t, o) {
|
|
4556
|
-
const n = new
|
|
4573
|
+
const n = new Fn(this.logger, this.getFilePath(t), t);
|
|
4557
4574
|
return n.attach(e, o), this.urlToDownload.set(t.toString(), n), n;
|
|
4558
4575
|
}
|
|
4559
4576
|
removeTask(e, t) {
|
|
@@ -4564,7 +4581,7 @@ class vr {
|
|
|
4564
4581
|
return b.join(this.saveDir, t);
|
|
4565
4582
|
}
|
|
4566
4583
|
}
|
|
4567
|
-
class
|
|
4584
|
+
class Fn {
|
|
4568
4585
|
constructor(e, t, o) {
|
|
4569
4586
|
d(this, "counter", new v());
|
|
4570
4587
|
d(this, "change", new N());
|
|
@@ -4591,7 +4608,7 @@ class En {
|
|
|
4591
4608
|
const o = await this.downloadAndUntar(e, t, this.signalCtl.signal);
|
|
4592
4609
|
this.setDone(o), this.change.markChanged();
|
|
4593
4610
|
} catch (o) {
|
|
4594
|
-
if (o instanceof
|
|
4611
|
+
if (o instanceof Ie || o instanceof V) {
|
|
4595
4612
|
this.setError(o), this.change.markChanged(), await de(this.path);
|
|
4596
4613
|
return;
|
|
4597
4614
|
}
|
|
@@ -4609,7 +4626,7 @@ class En {
|
|
|
4609
4626
|
}
|
|
4610
4627
|
return await ge(this.logger, this.path, async (a) => {
|
|
4611
4628
|
await m.mkdir(a);
|
|
4612
|
-
const i =
|
|
4629
|
+
const i = S.toWeb(ae.extract(a));
|
|
4613
4630
|
await r.pipeTo(i, { signal: o });
|
|
4614
4631
|
}), n.size;
|
|
4615
4632
|
}
|
|
@@ -4624,10 +4641,10 @@ class En {
|
|
|
4624
4641
|
this.error = String(e);
|
|
4625
4642
|
}
|
|
4626
4643
|
abort(e) {
|
|
4627
|
-
this.signalCtl.abort(new
|
|
4644
|
+
this.signalCtl.abort(new Ie(e));
|
|
4628
4645
|
}
|
|
4629
4646
|
}
|
|
4630
|
-
class
|
|
4647
|
+
class Ie extends Error {
|
|
4631
4648
|
}
|
|
4632
4649
|
async function et(s) {
|
|
4633
4650
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
@@ -4647,7 +4664,7 @@ function ve(s, e) {
|
|
|
4647
4664
|
path: e
|
|
4648
4665
|
}))}`;
|
|
4649
4666
|
}
|
|
4650
|
-
function
|
|
4667
|
+
function Wn(s, e, t, o) {
|
|
4651
4668
|
const n = {
|
|
4652
4669
|
localPath: s,
|
|
4653
4670
|
pathSignature: e.sign(s),
|
|
@@ -4656,31 +4673,31 @@ function On(s, e, t, o) {
|
|
|
4656
4673
|
};
|
|
4657
4674
|
return `upload://upload/${encodeURIComponent(JSON.stringify(n))}`;
|
|
4658
4675
|
}
|
|
4659
|
-
function
|
|
4676
|
+
function zn(s) {
|
|
4660
4677
|
const e = new URL(s);
|
|
4661
4678
|
return q.parse(
|
|
4662
4679
|
JSON.parse(decodeURIComponent(e.pathname.substring(1)))
|
|
4663
4680
|
);
|
|
4664
4681
|
}
|
|
4665
|
-
function
|
|
4682
|
+
function xn(s) {
|
|
4666
4683
|
const e = new URL(s);
|
|
4667
4684
|
return Ve.parse(JSON.parse(decodeURIComponent(e.pathname.substring(1))));
|
|
4668
4685
|
}
|
|
4669
|
-
function
|
|
4670
|
-
if (
|
|
4671
|
-
return
|
|
4672
|
-
if (
|
|
4673
|
-
return
|
|
4686
|
+
function An(s) {
|
|
4687
|
+
if (Gn(s))
|
|
4688
|
+
return qn(s);
|
|
4689
|
+
if (Mn(s))
|
|
4690
|
+
return jn(s);
|
|
4674
4691
|
ht(s);
|
|
4675
4692
|
}
|
|
4676
4693
|
const tt = /^local:\/\/(?<name>.*)\/(?<path>.*)$/;
|
|
4677
|
-
function
|
|
4694
|
+
function Mn(s) {
|
|
4678
4695
|
return tt.test(s);
|
|
4679
4696
|
}
|
|
4680
|
-
function
|
|
4697
|
+
function Hn(s, e) {
|
|
4681
4698
|
return `local://${s}/${encodeURIComponent(e)}`;
|
|
4682
4699
|
}
|
|
4683
|
-
function
|
|
4700
|
+
function jn(s) {
|
|
4684
4701
|
const e = s.match(tt);
|
|
4685
4702
|
if (e == null) throw new Error(`Local list handle wasn't parsed: ${s}`);
|
|
4686
4703
|
const { name: t, path: o } = e.groups;
|
|
@@ -4691,27 +4708,27 @@ function Mn(s) {
|
|
|
4691
4708
|
};
|
|
4692
4709
|
}
|
|
4693
4710
|
const ot = /^remote:\/\/(?<name>.*)\/(?<resourceId>.*)$/;
|
|
4694
|
-
function
|
|
4711
|
+
function Gn(s) {
|
|
4695
4712
|
return ot.test(s);
|
|
4696
4713
|
}
|
|
4697
|
-
function
|
|
4714
|
+
function Vn(s, e) {
|
|
4698
4715
|
return `remote://${s}/${BigInt(e)}`;
|
|
4699
4716
|
}
|
|
4700
|
-
function
|
|
4717
|
+
function qn(s) {
|
|
4701
4718
|
const e = s.match(ot);
|
|
4702
4719
|
if (e == null) throw new Error(`Remote list handle wasn't parsed: ${s}`);
|
|
4703
4720
|
const { name: t, resourceId: o } = e.groups;
|
|
4704
4721
|
return {
|
|
4705
4722
|
id: he(BigInt(o)),
|
|
4706
|
-
type:
|
|
4723
|
+
type: Jn(t),
|
|
4707
4724
|
name: t,
|
|
4708
4725
|
isRemote: !0
|
|
4709
4726
|
};
|
|
4710
4727
|
}
|
|
4711
|
-
function
|
|
4728
|
+
function Jn(s) {
|
|
4712
4729
|
return { name: `LS/${s}`, version: "1" };
|
|
4713
4730
|
}
|
|
4714
|
-
async function
|
|
4731
|
+
async function Zn() {
|
|
4715
4732
|
const s = ft.homedir();
|
|
4716
4733
|
if (L.sep == "/")
|
|
4717
4734
|
return [
|
|
@@ -4777,12 +4794,12 @@ class nt {
|
|
|
4777
4794
|
*/
|
|
4778
4795
|
async tryResolveLocalFileHandle(e) {
|
|
4779
4796
|
if (bt(e)) {
|
|
4780
|
-
const t =
|
|
4797
|
+
const t = xn(e), o = this.localProjectionsMap.get(t.storageId);
|
|
4781
4798
|
if (!o)
|
|
4782
4799
|
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
4783
4800
|
return b.join(o.localPath, t.path);
|
|
4784
4801
|
} else {
|
|
4785
|
-
const t =
|
|
4802
|
+
const t = zn(e);
|
|
4786
4803
|
this.signer.verify(
|
|
4787
4804
|
t.localPath,
|
|
4788
4805
|
t.pathSignature,
|
|
@@ -4805,7 +4822,7 @@ class nt {
|
|
|
4805
4822
|
);
|
|
4806
4823
|
}
|
|
4807
4824
|
const t = await m.stat(e, { bigint: !0 });
|
|
4808
|
-
return
|
|
4825
|
+
return Wn(
|
|
4809
4826
|
e,
|
|
4810
4827
|
this.signer,
|
|
4811
4828
|
t.size,
|
|
@@ -4816,12 +4833,12 @@ class nt {
|
|
|
4816
4833
|
async getStorageList() {
|
|
4817
4834
|
const e = [...this.virtualStoragesMap.values()].map((n) => ({
|
|
4818
4835
|
name: n.name,
|
|
4819
|
-
handle:
|
|
4836
|
+
handle: Hn(n.name, n.root),
|
|
4820
4837
|
initialFullPath: n.initialPath
|
|
4821
4838
|
})), o = Object.entries(this.storageIdToResourceId).map(
|
|
4822
4839
|
([n, r]) => ({
|
|
4823
4840
|
name: n,
|
|
4824
|
-
handle:
|
|
4841
|
+
handle: Vn(n, r),
|
|
4825
4842
|
initialFullPath: "",
|
|
4826
4843
|
// we don't have any additional information from where to start browsing remote storages
|
|
4827
4844
|
isInitialPathHome: !1
|
|
@@ -4830,7 +4847,7 @@ class nt {
|
|
|
4830
4847
|
return [...e, ...o];
|
|
4831
4848
|
}
|
|
4832
4849
|
async listFiles(e, t) {
|
|
4833
|
-
const o =
|
|
4850
|
+
const o = An(e);
|
|
4834
4851
|
if (o.isRemote)
|
|
4835
4852
|
return {
|
|
4836
4853
|
entries: (await this.lsClient.list(o, t)).items.map((i) => ({
|
|
@@ -4861,7 +4878,7 @@ class nt {
|
|
|
4861
4878
|
}
|
|
4862
4879
|
static async init(e, t, o, n, r, a) {
|
|
4863
4880
|
const i = Xo(t, e);
|
|
4864
|
-
a || (a = await
|
|
4881
|
+
a || (a = await Zn());
|
|
4865
4882
|
for (const p of a) C(p.root);
|
|
4866
4883
|
for (const p of n) p.localPath !== "" && C(p.localPath);
|
|
4867
4884
|
const c = new Map(a.map((p) => [p.name, p])), l = new Map(n.map((p) => [p.storageId, p]));
|
|
@@ -4872,7 +4889,7 @@ class nt {
|
|
|
4872
4889
|
return new nt(
|
|
4873
4890
|
e,
|
|
4874
4891
|
i,
|
|
4875
|
-
await
|
|
4892
|
+
await Qn(t),
|
|
4876
4893
|
o,
|
|
4877
4894
|
c,
|
|
4878
4895
|
l,
|
|
@@ -4880,13 +4897,13 @@ class nt {
|
|
|
4880
4897
|
);
|
|
4881
4898
|
}
|
|
4882
4899
|
}
|
|
4883
|
-
async function
|
|
4900
|
+
async function Qn(s) {
|
|
4884
4901
|
return s.withReadTx("GetAvailableStorageIds", async (e) => {
|
|
4885
4902
|
const t = await e.getResourceByName("LSProvider"), o = await e.getResourceData(t, !0);
|
|
4886
|
-
return
|
|
4903
|
+
return Xn(o);
|
|
4887
4904
|
});
|
|
4888
4905
|
}
|
|
4889
|
-
function
|
|
4906
|
+
function Xn(s) {
|
|
4890
4907
|
return Object.fromEntries(
|
|
4891
4908
|
s.fields.filter((e) => e.type == "Dynamic" && lt(e.value)).map((e) => [e.name.substring(8), e.value])
|
|
4892
4909
|
);
|
|
@@ -4897,17 +4914,17 @@ export {
|
|
|
4897
4914
|
Oo as ClientLs,
|
|
4898
4915
|
ho as ClientProgress,
|
|
4899
4916
|
Gt as ClientUpload,
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4917
|
+
Zn as DefaultVirtualLocalStorages,
|
|
4918
|
+
Sr as DownloadBlobToURLDriver,
|
|
4919
|
+
Dr as DownloadDriver,
|
|
4920
|
+
Br as DownloadUrlDriver,
|
|
4904
4921
|
gn as DownloadableBlobSnapshot,
|
|
4905
|
-
|
|
4922
|
+
Ur as ImportFileHandleData,
|
|
4906
4923
|
Ve as ImportFileHandleIndexData,
|
|
4907
4924
|
q as ImportFileHandleUploadData,
|
|
4908
4925
|
rn as IndexResourceSnapshot,
|
|
4909
|
-
|
|
4910
|
-
|
|
4926
|
+
Nr as LogsDriver,
|
|
4927
|
+
vr as LogsStreamDriver,
|
|
4911
4928
|
nt as LsDriver,
|
|
4912
4929
|
ze as MTimeError,
|
|
4913
4930
|
Ae as NetworkError,
|
|
@@ -4916,21 +4933,26 @@ export {
|
|
|
4916
4933
|
xe as UnexpectedEOF,
|
|
4917
4934
|
be as UnknownStorageError,
|
|
4918
4935
|
dn as Updater,
|
|
4919
|
-
|
|
4936
|
+
Ir as UploadDriver,
|
|
4920
4937
|
nn as UploadResourceSnapshot,
|
|
4938
|
+
Ln as UploadTask,
|
|
4921
4939
|
ye as WrongLocalFileUrl,
|
|
4922
4940
|
Le as WrongResourceTypeError,
|
|
4923
|
-
|
|
4924
|
-
|
|
4941
|
+
Tr as createDownloadClient,
|
|
4942
|
+
kr as createLogsClient,
|
|
4925
4943
|
Xo as createLsFilesClient,
|
|
4926
|
-
|
|
4927
|
-
|
|
4944
|
+
Pr as createUploadBlobClient,
|
|
4945
|
+
Lr as createUploadProgressClient,
|
|
4928
4946
|
Po as getFullPath,
|
|
4929
4947
|
on as getSize,
|
|
4930
|
-
|
|
4948
|
+
Dn as isMyUpload,
|
|
4949
|
+
Re as isResourceWasDeletedError,
|
|
4950
|
+
_n as makeBlobImportSnapshot,
|
|
4931
4951
|
fn as makeDownloadableBlobSnapshot,
|
|
4932
4952
|
Ro as newLocalStorageIdsToRoot,
|
|
4953
|
+
Ye as nonRecoverableError,
|
|
4933
4954
|
Lo as parseLocalUrl,
|
|
4955
|
+
Pn as uploadBlob,
|
|
4934
4956
|
C as validateAbsolute
|
|
4935
4957
|
};
|
|
4936
4958
|
//# sourceMappingURL=index.mjs.map
|