@milaboratories/pl-drivers 1.5.71 → 1.5.72
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/download_blob_task.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/clients/download.ts +2 -2
- package/src/drivers/download_blob/download_blob_task.ts +11 -4
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var yt = Object.defineProperty;
|
|
2
2
|
var bt = (s, e, t) => e in s ? yt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var h = (s, e, t) => bt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { addRTypeToMetadata as S,
|
|
4
|
+
import { addRTypeToMetadata as S, stringifyWithResourceId as w, bigintToResourceId as Te, resourceIdToString as Tt, isNotNullResourceId as kt } from "@milaboratories/pl-client";
|
|
5
5
|
import * as m from "node:fs/promises";
|
|
6
6
|
import { request as ze } from "undici";
|
|
7
7
|
import { ServiceType as O, stackIntercept as L } from "@protobuf-ts/runtime-rpc";
|
|
@@ -9,11 +9,11 @@ import { MessageType as g, reflectionMergePartial as f, UnknownFieldHandler as u
|
|
|
9
9
|
import { notEmpty as q, CallersCounter as N, ensureDirExists as E, fileExists as F, createPathAtomically as J, mapGet as pe, mapEntries as xe, spawnAsync as Pt, TaskProcessor as Z, asyncPool as ke, assertNever as St } from "@milaboratories/ts-helpers";
|
|
10
10
|
import * as Le from "node:fs";
|
|
11
11
|
import ge, { promises as fe } from "node:fs";
|
|
12
|
-
import * as
|
|
12
|
+
import * as T from "node:path";
|
|
13
13
|
import P from "node:path";
|
|
14
14
|
import { Readable as Pe, Writable as v, Transform as Ae } from "node:stream";
|
|
15
15
|
import { text as Rt, buffer as Me } from "node:stream/consumers";
|
|
16
|
-
import { ChangeSource as $, Computable as
|
|
16
|
+
import { ChangeSource as $, Computable as y, PollingComputableHooks as He } from "@milaboratories/computable";
|
|
17
17
|
import { RangeBytes as Ut, validateRangeBytes as Ie, isImportFileHandleIndex as Dt } from "@milaboratories/pl-model-common";
|
|
18
18
|
import { rsSchema as Q, treeEntryToResourceInfo as D, isPlTreeEntry as z, makeResourceSnapshot as j, isPlTreeEntryAccessor as je } from "@milaboratories/pl-tree";
|
|
19
19
|
import vt from "denque";
|
|
@@ -1895,7 +1895,7 @@ class On {
|
|
|
1895
1895
|
*/
|
|
1896
1896
|
async downloadBlob(e, t, n, o, r) {
|
|
1897
1897
|
const { downloadUrl: a, headers: i } = await this.grpcGetDownloadUrl(e, t, n), c = qe(i, o, r);
|
|
1898
|
-
return this.logger.info(`download blob from url ${a}, headers: ${JSON.stringify(c)}`), xn(a) ? await this.readLocalFile(a, o, r) : await this.remoteFileDownloader.download(a, c, n);
|
|
1898
|
+
return this.logger.info(`download blob ${w(e)} from url ${a}, headers: ${JSON.stringify(c)}`), xn(a) ? await this.readLocalFile(a, o, r) : await this.remoteFileDownloader.download(a, c, n);
|
|
1899
1899
|
}
|
|
1900
1900
|
async readLocalFile(e, t, n) {
|
|
1901
1901
|
const { storageId: o, relativePath: r } = Fn(e), a = zn(o, this.localStorageIdsToRoot, r);
|
|
@@ -1924,7 +1924,7 @@ function Fn(s) {
|
|
|
1924
1924
|
function zn(s, e, t) {
|
|
1925
1925
|
const n = e.get(s);
|
|
1926
1926
|
if (n === void 0) throw new Re(`Unknown storage location: ${s}`);
|
|
1927
|
-
return n === "" ? t :
|
|
1927
|
+
return n === "" ? t : T.join(n, t);
|
|
1928
1928
|
}
|
|
1929
1929
|
const Wn = "storage://";
|
|
1930
1930
|
function xn(s) {
|
|
@@ -3336,11 +3336,11 @@ function V(s) {
|
|
|
3336
3336
|
type: { name: t, version: n }
|
|
3337
3337
|
};
|
|
3338
3338
|
}
|
|
3339
|
-
function
|
|
3339
|
+
function b(s) {
|
|
3340
3340
|
return `${BigInt(s)}`;
|
|
3341
3341
|
}
|
|
3342
3342
|
function $e(s) {
|
|
3343
|
-
return
|
|
3343
|
+
return T.basename(s);
|
|
3344
3344
|
}
|
|
3345
3345
|
class So {
|
|
3346
3346
|
constructor(e, t, n, o, r) {
|
|
@@ -3371,24 +3371,26 @@ class So {
|
|
|
3371
3371
|
const e = await this.ensureDownloaded();
|
|
3372
3372
|
this.setDone(e), this.change.markChanged();
|
|
3373
3373
|
} catch (e) {
|
|
3374
|
-
throw this.logger.error(`
|
|
3374
|
+
throw this.logger.error(`download blob ${w(this.rInfo)} failed: ${e}, state: ${JSON.stringify(this.state)}`), De(e) && (this.setError(e), this.change.markChanged(), await m.rm(this.path)), e;
|
|
3375
3375
|
}
|
|
3376
3376
|
}
|
|
3377
3377
|
async ensureDownloaded() {
|
|
3378
|
-
|
|
3378
|
+
this.signalCtl.signal.throwIfAborted(), this.state = {}, this.state.filePath = this.path, await E(T.dirname(this.state.filePath)), this.signalCtl.signal.throwIfAborted(), this.state.dirExists = !0;
|
|
3379
|
+
const e = await F(this.state.filePath);
|
|
3380
|
+
if (this.signalCtl.signal.throwIfAborted(), e) {
|
|
3379
3381
|
this.state.fileExists = !0, this.logger.info(`a blob was already downloaded: ${this.state.filePath}`);
|
|
3380
|
-
const
|
|
3381
|
-
return this.state.fileSize =
|
|
3382
|
+
const o = await m.stat(this.state.filePath);
|
|
3383
|
+
return this.signalCtl.signal.throwIfAborted(), this.state.fileSize = o.size, this.state.fileSize;
|
|
3382
3384
|
}
|
|
3383
|
-
const { content:
|
|
3385
|
+
const { content: t, size: n } = await this.clientDownload.downloadBlob(
|
|
3384
3386
|
this.rInfo,
|
|
3385
3387
|
{},
|
|
3386
|
-
|
|
3388
|
+
this.signalCtl.signal
|
|
3387
3389
|
);
|
|
3388
|
-
return this.state.fileSize =
|
|
3389
|
-
const
|
|
3390
|
-
await
|
|
3391
|
-
}), this.state.done = !0,
|
|
3390
|
+
return this.state.fileSize = n, this.state.downloaded = !0, await J(this.logger, this.state.filePath, async (o) => {
|
|
3391
|
+
const r = v.toWeb(ge.createWriteStream(o, { flags: "wx" }));
|
|
3392
|
+
await t.pipeTo(r, { signal: this.signalCtl.signal }), this.state.tempWritten = !0;
|
|
3393
|
+
}), this.state.done = !0, n;
|
|
3392
3394
|
}
|
|
3393
3395
|
abort(e) {
|
|
3394
3396
|
this.signalCtl.abort(new it(e));
|
|
@@ -3677,7 +3679,7 @@ class ct {
|
|
|
3677
3679
|
h(this, "saveDir");
|
|
3678
3680
|
this.logger = e, this.clientDownload = t, this.clientLogs = n, this.rangesCacheDir = r, this.signer = a, this.ops = i, this.cache = new ve(this.ops.cacheSoftSizeBytes);
|
|
3679
3681
|
const c = new Fo(this.logger, this.rangesCacheDir), l = new zo(this.logger, this.rangesCacheDir);
|
|
3680
|
-
this.rangesCache = new Wo(this.logger, this.ops.rangesCacheMaxSizeBytes, c, l), this.downloadQueue = new Z(this.logger, i.nConcurrentDownloads), this.saveDir =
|
|
3682
|
+
this.rangesCache = new Wo(this.logger, this.ops.rangesCacheMaxSizeBytes, c, l), this.downloadQueue = new Z(this.logger, i.nConcurrentDownloads), this.saveDir = T.resolve(o);
|
|
3681
3683
|
}
|
|
3682
3684
|
static async init(e, t, n, o, r, a, i) {
|
|
3683
3685
|
const c = new ct(e, t, n, o, r, a, i);
|
|
@@ -3685,7 +3687,7 @@ class ct {
|
|
|
3685
3687
|
}
|
|
3686
3688
|
getDownloadedBlob(e, t) {
|
|
3687
3689
|
if (t === void 0)
|
|
3688
|
-
return
|
|
3690
|
+
return y.make((a) => this.getDownloadedBlob(e, a));
|
|
3689
3691
|
const n = D(e, t), o = R();
|
|
3690
3692
|
t.addOnDestroy(() => this.releaseBlob(n, o));
|
|
3691
3693
|
const r = this.getDownloadedBlobNoCtx(t.watcher, n, o);
|
|
@@ -3703,10 +3705,10 @@ class ct {
|
|
|
3703
3705
|
}
|
|
3704
3706
|
}
|
|
3705
3707
|
getOrSetNewTask(e, t) {
|
|
3706
|
-
const n =
|
|
3708
|
+
const n = b(e.id), o = this.keyToDownload.get(n);
|
|
3707
3709
|
if (o)
|
|
3708
3710
|
return o;
|
|
3709
|
-
const r =
|
|
3711
|
+
const r = T.resolve(this.saveDir, n), a = new So(
|
|
3710
3712
|
this.logger,
|
|
3711
3713
|
this.clientDownload,
|
|
3712
3714
|
e,
|
|
@@ -3724,14 +3726,14 @@ class ct {
|
|
|
3724
3726
|
n.done && n.result.ok && this.cache.addCache(e, t);
|
|
3725
3727
|
}
|
|
3726
3728
|
getOnDemandBlob(e, t) {
|
|
3727
|
-
if (t === void 0) return
|
|
3729
|
+
if (t === void 0) return y.make((a) => this.getOnDemandBlob(e, a));
|
|
3728
3730
|
const n = z(e) ? j(e, mo, t) : e, o = R();
|
|
3729
3731
|
return t.addOnDestroy(() => this.releaseOnDemandBlob(n.id, o)), this.getOnDemandBlobNoCtx(n, o);
|
|
3730
3732
|
}
|
|
3731
3733
|
getOnDemandBlobNoCtx(e, t) {
|
|
3732
3734
|
C("getOnDemandBlob", e.type);
|
|
3733
|
-
let n = this.keyToOnDemand.get(
|
|
3734
|
-
return n === void 0 && (n = new xo(et(e), bo(e, this.signer)), this.keyToOnDemand.set(
|
|
3735
|
+
let n = this.keyToOnDemand.get(b(e.id));
|
|
3736
|
+
return n === void 0 && (n = new xo(et(e), bo(e, this.signer)), this.keyToOnDemand.set(b(e.id), n)), n.attach(t), n.getHandle();
|
|
3735
3737
|
}
|
|
3736
3738
|
/** Gets a path from a handle. */
|
|
3737
3739
|
getLocalPath(e) {
|
|
@@ -3743,7 +3745,7 @@ class ct {
|
|
|
3743
3745
|
if (t && Ie(t, "getContent"), fo(e))
|
|
3744
3746
|
return await Ce(this.getLocalPath(e), t);
|
|
3745
3747
|
if (To(e)) {
|
|
3746
|
-
const n = ko(e, this.signer), o =
|
|
3748
|
+
const n = ko(e, this.signer), o = b(n.info.id), r = await this.rangesCache.get(o, t ?? { from: 0, to: n.size });
|
|
3747
3749
|
if (r)
|
|
3748
3750
|
return await Ce(r, t);
|
|
3749
3751
|
const { content: a } = await this.clientDownload.downloadBlob(
|
|
@@ -3762,7 +3764,7 @@ class ct {
|
|
|
3762
3764
|
* Uses downloaded blob handle under the hood, so stores corresponding blob in file system.
|
|
3763
3765
|
*/
|
|
3764
3766
|
getComputableContent(e, t) {
|
|
3765
|
-
return t && Ie(t, "getComputableContent"),
|
|
3767
|
+
return t && Ie(t, "getComputableContent"), y.make(
|
|
3766
3768
|
(n) => this.getDownloadedBlob(e, n),
|
|
3767
3769
|
{
|
|
3768
3770
|
postprocessValue: (n) => n ? this.getContent(n.handle, t) : void 0
|
|
@@ -3770,7 +3772,7 @@ class ct {
|
|
|
3770
3772
|
).withStableType();
|
|
3771
3773
|
}
|
|
3772
3774
|
getLastLogs(e, t, n) {
|
|
3773
|
-
if (n == null) return
|
|
3775
|
+
if (n == null) return y.make((i) => this.getLastLogs(e, t, i));
|
|
3774
3776
|
const o = D(e, n), r = R();
|
|
3775
3777
|
n.addOnDestroy(() => this.releaseBlob(o, r));
|
|
3776
3778
|
const a = this.getLastLogsNoCtx(n.watcher, o, t, r);
|
|
@@ -3781,10 +3783,10 @@ class ct {
|
|
|
3781
3783
|
const r = this.getDownloadedBlobNoCtx(e, t, o);
|
|
3782
3784
|
if (r == null) return;
|
|
3783
3785
|
const { path: a } = ce(r.handle, this.signer);
|
|
3784
|
-
let i = this.idToLastLines.get(
|
|
3786
|
+
let i = this.idToLastLines.get(b(t.id));
|
|
3785
3787
|
if (i == null) {
|
|
3786
3788
|
const l = new Be(a, n);
|
|
3787
|
-
this.idToLastLines.set(
|
|
3789
|
+
this.idToLastLines.set(b(t.id), l), i = l;
|
|
3788
3790
|
}
|
|
3789
3791
|
const c = i.getOrSchedule(e);
|
|
3790
3792
|
if (c.error) throw c.error;
|
|
@@ -3792,7 +3794,7 @@ class ct {
|
|
|
3792
3794
|
}
|
|
3793
3795
|
getProgressLog(e, t, n) {
|
|
3794
3796
|
if (n == null)
|
|
3795
|
-
return
|
|
3797
|
+
return y.make((i) => this.getProgressLog(e, t, i));
|
|
3796
3798
|
const o = D(e, n), r = R();
|
|
3797
3799
|
n.addOnDestroy(() => this.releaseBlob(o, r));
|
|
3798
3800
|
const a = this.getProgressLogNoCtx(
|
|
@@ -3808,17 +3810,17 @@ class ct {
|
|
|
3808
3810
|
const r = this.getDownloadedBlobNoCtx(e, t, o);
|
|
3809
3811
|
if (r == null) return;
|
|
3810
3812
|
const { path: a } = ce(r.handle, this.signer);
|
|
3811
|
-
let i = this.idToProgressLog.get(
|
|
3813
|
+
let i = this.idToProgressLog.get(b(t.id));
|
|
3812
3814
|
if (i == null) {
|
|
3813
3815
|
const l = new Be(a, 1, n);
|
|
3814
|
-
this.idToProgressLog.set(
|
|
3816
|
+
this.idToProgressLog.set(b(t.id), l), i = l;
|
|
3815
3817
|
}
|
|
3816
3818
|
const c = i.getOrSchedule(e);
|
|
3817
3819
|
if (c.error) throw c.error;
|
|
3818
3820
|
return c.log;
|
|
3819
3821
|
}
|
|
3820
3822
|
getLogHandle(e, t) {
|
|
3821
|
-
if (t == null) return
|
|
3823
|
+
if (t == null) return y.make((o) => this.getLogHandle(e, o));
|
|
3822
3824
|
const n = D(e, t);
|
|
3823
3825
|
return this.getLogHandleNoCtx(n);
|
|
3824
3826
|
}
|
|
@@ -3856,30 +3858,30 @@ class ct {
|
|
|
3856
3858
|
};
|
|
3857
3859
|
}
|
|
3858
3860
|
async releaseBlob(e, t) {
|
|
3859
|
-
const n = this.keyToDownload.get(
|
|
3861
|
+
const n = this.keyToDownload.get(b(e.id));
|
|
3860
3862
|
if (n != null)
|
|
3861
|
-
if (this.cache.existsFile(
|
|
3862
|
-
const o = this.cache.removeFile(
|
|
3863
|
+
if (this.cache.existsFile(b(e.id))) {
|
|
3864
|
+
const o = this.cache.removeFile(b(e.id), t);
|
|
3863
3865
|
await Promise.all(
|
|
3864
3866
|
o.map(async (r) => {
|
|
3865
3867
|
await m.rm(r.path), this.cache.removeCache(r), this.removeTask(
|
|
3866
3868
|
pe(this.keyToDownload, $e(r.path)),
|
|
3867
|
-
`the task ${
|
|
3869
|
+
`the task ${w(r)} was removedfrom cache along with ${w(o.map((a) => a.path))}`
|
|
3868
3870
|
);
|
|
3869
3871
|
})
|
|
3870
3872
|
);
|
|
3871
3873
|
} else
|
|
3872
3874
|
n.counter.dec(t) && this.removeTask(
|
|
3873
3875
|
n,
|
|
3874
|
-
`the task ${
|
|
3876
|
+
`the task ${w(n.info())} was removed from cache`
|
|
3875
3877
|
);
|
|
3876
3878
|
}
|
|
3877
3879
|
removeTask(e, t) {
|
|
3878
|
-
e.abort(t), e.change.markChanged(), this.keyToDownload.delete($e(e.path)), this.idToLastLines.delete(
|
|
3880
|
+
e.abort(t), e.change.markChanged(), this.keyToDownload.delete($e(e.path)), this.idToLastLines.delete(b(e.rInfo.id)), this.idToProgressLog.delete(b(e.rInfo.id));
|
|
3879
3881
|
}
|
|
3880
3882
|
async releaseOnDemandBlob(e, t) {
|
|
3881
3883
|
var o;
|
|
3882
|
-
(((o = this.keyToOnDemand.get(
|
|
3884
|
+
(((o = this.keyToOnDemand.get(b(e))) == null ? void 0 : o.release(t)) ?? !1) && this.keyToOnDemand.delete(b(e));
|
|
3883
3885
|
}
|
|
3884
3886
|
/** Removes all files from a hard drive. */
|
|
3885
3887
|
async releaseAll() {
|
|
@@ -4007,9 +4009,9 @@ class Jo {
|
|
|
4007
4009
|
async download() {
|
|
4008
4010
|
try {
|
|
4009
4011
|
const e = await this.downloadAndDecompress(this.signalCtl.signal);
|
|
4010
|
-
this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${
|
|
4012
|
+
this.setDone(e), this.change.markChanged(), this.logger.info(`blob to URL task is done: ${w(this.info())}`);
|
|
4011
4013
|
} catch (e) {
|
|
4012
|
-
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${
|
|
4014
|
+
if (this.logger.warn(`a error was produced: ${e} for blob to URL task: ${w(this.info())}`), Zo(e)) {
|
|
4013
4015
|
this.setError(e), this.change.markChanged(), await we(this.path);
|
|
4014
4016
|
return;
|
|
4015
4017
|
}
|
|
@@ -4124,7 +4126,7 @@ class es {
|
|
|
4124
4126
|
}
|
|
4125
4127
|
extractArchiveAndGetURL(e, t, n) {
|
|
4126
4128
|
if (n === void 0)
|
|
4127
|
-
return
|
|
4129
|
+
return y.make((i) => this.extractArchiveAndGetURL(e, t, i));
|
|
4128
4130
|
const o = z(e) ? Ho(e, n) : e, r = R();
|
|
4129
4131
|
n.addOnDestroy(() => this.releasePath(o.id, t, r));
|
|
4130
4132
|
const a = this.extractArchiveAndGetURLNoCtx(o, t, n.watcher, r);
|
|
@@ -4160,14 +4162,14 @@ class es {
|
|
|
4160
4162
|
r.map(async (a) => {
|
|
4161
4163
|
await we(a.path), this.cache.removeCache(a), this.removeTask(
|
|
4162
4164
|
a,
|
|
4163
|
-
`the task ${
|
|
4165
|
+
`the task ${w(a.info())} was removedfrom cache along with ${w(r.map((i) => i.info()))}`
|
|
4164
4166
|
);
|
|
4165
4167
|
})
|
|
4166
4168
|
);
|
|
4167
4169
|
} else
|
|
4168
4170
|
o.counter.dec(n) && this.removeTask(
|
|
4169
4171
|
o,
|
|
4170
|
-
`the task ${
|
|
4172
|
+
`the task ${w(o.info())} was removed from cache`
|
|
4171
4173
|
);
|
|
4172
4174
|
}
|
|
4173
4175
|
/** Removes all files from a hard drive. */
|
|
@@ -4176,7 +4178,7 @@ class es {
|
|
|
4176
4178
|
Array.from(this.idToDownload.entries()).map(async ([e, t]) => {
|
|
4177
4179
|
await we(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4178
4180
|
t,
|
|
4179
|
-
`the task ${
|
|
4181
|
+
`the task ${w(t.info())} was released when the driver was closed`
|
|
4180
4182
|
);
|
|
4181
4183
|
})
|
|
4182
4184
|
);
|
|
@@ -4197,7 +4199,7 @@ class es {
|
|
|
4197
4199
|
e.abort(t), e.change.markChanged(), this.idToDownload.delete(x(e.rInfo.id, e.format));
|
|
4198
4200
|
}
|
|
4199
4201
|
getFilePath(e, t) {
|
|
4200
|
-
return
|
|
4202
|
+
return T.join(this.saveDir, `${String(BigInt(e))}_${t}`);
|
|
4201
4203
|
}
|
|
4202
4204
|
}
|
|
4203
4205
|
class Qo {
|
|
@@ -4268,7 +4270,7 @@ class Qo {
|
|
|
4268
4270
|
}
|
|
4269
4271
|
if (_e(t)) {
|
|
4270
4272
|
this.logger.warn(
|
|
4271
|
-
`resource was not found while updating a status of BlobImport: ${t}, ${
|
|
4273
|
+
`resource was not found while updating a status of BlobImport: ${t}, ${w(this.res)}`
|
|
4272
4274
|
), this.change.markChanged(), this.setDone(!0);
|
|
4273
4275
|
return;
|
|
4274
4276
|
}
|
|
@@ -4416,7 +4418,7 @@ class ts {
|
|
|
4416
4418
|
);
|
|
4417
4419
|
}
|
|
4418
4420
|
getProgressId(e, t) {
|
|
4419
|
-
if (t == null) return
|
|
4421
|
+
if (t == null) return y.make((a) => this.getProgressId(e, a));
|
|
4420
4422
|
const n = z(e) ? lr(e, t) : e, o = R();
|
|
4421
4423
|
return t.attacheHooks(this.hooks), t.addOnDestroy(() => this.release(n.id, o)), this.getProgressIdNoCtx(t.watcher, n, o);
|
|
4422
4424
|
}
|
|
@@ -4515,7 +4517,7 @@ class ns {
|
|
|
4515
4517
|
);
|
|
4516
4518
|
}
|
|
4517
4519
|
getLastLogs(e, t, n) {
|
|
4518
|
-
if (n == null) return
|
|
4520
|
+
if (n == null) return y.make((i) => this.getLastLogs(e, t, i));
|
|
4519
4521
|
const o = D(e, n), r = R();
|
|
4520
4522
|
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseLastLogs(o.id, r));
|
|
4521
4523
|
const a = this.getLastLogsNoCtx(n.watcher, o, t, r);
|
|
@@ -4537,7 +4539,7 @@ class ns {
|
|
|
4537
4539
|
}
|
|
4538
4540
|
getProgressLog(e, t, n) {
|
|
4539
4541
|
if (n == null)
|
|
4540
|
-
return
|
|
4542
|
+
return y.make((i) => this.getProgressLog(e, t, i));
|
|
4541
4543
|
const o = D(e, n), r = R();
|
|
4542
4544
|
n.attacheHooks(this.hooks), n.addOnDestroy(() => this.releaseProgressLog(o.id, r));
|
|
4543
4545
|
const a = this.getProgressLogNoCtx(n.watcher, o, t, r);
|
|
@@ -4558,7 +4560,7 @@ class ns {
|
|
|
4558
4560
|
return a.log;
|
|
4559
4561
|
}
|
|
4560
4562
|
getLogHandle(e, t) {
|
|
4561
|
-
if (t == null) return
|
|
4563
|
+
if (t == null) return y.make((r) => this.getLogHandle(e, r));
|
|
4562
4564
|
const n = D(e, t), o = this.getLogHandleNoCtx(n);
|
|
4563
4565
|
return t.markUnstable(`live_log:${Tt(n.id)}`), o;
|
|
4564
4566
|
}
|
|
@@ -4684,7 +4686,7 @@ class Ee {
|
|
|
4684
4686
|
return;
|
|
4685
4687
|
}
|
|
4686
4688
|
throw this.logger.error(
|
|
4687
|
-
`Stream log lines for ${
|
|
4689
|
+
`Stream log lines for ${w(this.rInfo.id)} failed, reason: ${e}`
|
|
4688
4690
|
), e;
|
|
4689
4691
|
}
|
|
4690
4692
|
}
|
|
@@ -4700,7 +4702,7 @@ class os {
|
|
|
4700
4702
|
this.logger = e, this.logsStreamDriver = t, this.downloadDriver = n;
|
|
4701
4703
|
}
|
|
4702
4704
|
getLastLogs(e, t, n) {
|
|
4703
|
-
if (n === void 0) return
|
|
4705
|
+
if (n === void 0) return y.make((r) => this.getLastLogs(e, t, r));
|
|
4704
4706
|
const o = M(n, e);
|
|
4705
4707
|
if (o === void 0) {
|
|
4706
4708
|
n.markUnstable("no stream in stream manager");
|
|
@@ -4719,7 +4721,7 @@ class os {
|
|
|
4719
4721
|
}
|
|
4720
4722
|
getProgressLog(e, t, n) {
|
|
4721
4723
|
if (n === void 0)
|
|
4722
|
-
return
|
|
4724
|
+
return y.make((r) => this.getProgressLog(e, t, r));
|
|
4723
4725
|
const o = M(n, e);
|
|
4724
4726
|
if (o === void 0) {
|
|
4725
4727
|
n.markUnstable("no stream in stream manager");
|
|
@@ -4738,7 +4740,7 @@ class os {
|
|
|
4738
4740
|
}
|
|
4739
4741
|
getProgressLogWithInfo(e, t, n) {
|
|
4740
4742
|
if (n === void 0)
|
|
4741
|
-
return
|
|
4743
|
+
return y.make((r) => this.getProgressLogWithInfo(e, t, r));
|
|
4742
4744
|
const o = M(n, e);
|
|
4743
4745
|
if (o === void 0) {
|
|
4744
4746
|
n.markUnstable("no stream in stream manager");
|
|
@@ -4763,7 +4765,7 @@ class os {
|
|
|
4763
4765
|
}
|
|
4764
4766
|
}
|
|
4765
4767
|
getLogHandle(e, t) {
|
|
4766
|
-
if (t === void 0) return
|
|
4768
|
+
if (t === void 0) return y.make((o) => this.getLogHandle(e, o));
|
|
4767
4769
|
const n = M(t, e);
|
|
4768
4770
|
if (n === void 0) {
|
|
4769
4771
|
t.markUnstable("no stream in stream manager");
|
|
@@ -4801,7 +4803,7 @@ class rs {
|
|
|
4801
4803
|
this.logger = e, this.saveDir = n, this.opts = o, this.downloadQueue = new Z(this.logger, this.opts.nConcurrentDownloads), this.cache = new ve(this.opts.cacheSoftSizeBytes), this.downloadHelper = new Xe(t);
|
|
4802
4804
|
}
|
|
4803
4805
|
getPath(e, t) {
|
|
4804
|
-
if (t === void 0) return
|
|
4806
|
+
if (t === void 0) return y.make((r) => this.getPath(e, r));
|
|
4805
4807
|
const n = R();
|
|
4806
4808
|
t.addOnDestroy(() => this.releasePath(e, n));
|
|
4807
4809
|
const o = this.getPathNoCtx(e, t.watcher, n);
|
|
@@ -4835,14 +4837,14 @@ class rs {
|
|
|
4835
4837
|
r.map(async (a) => {
|
|
4836
4838
|
await be(a.path), this.cache.removeCache(a), this.removeTask(
|
|
4837
4839
|
a,
|
|
4838
|
-
`the task ${
|
|
4840
|
+
`the task ${w(a.info())} was removedfrom cache along with ${w(r.map((i) => i.info()))}`
|
|
4839
4841
|
);
|
|
4840
4842
|
})
|
|
4841
4843
|
);
|
|
4842
4844
|
} else
|
|
4843
4845
|
o.counter.dec(t) && this.removeTask(
|
|
4844
4846
|
o,
|
|
4845
|
-
`the task ${
|
|
4847
|
+
`the task ${w(o.info())} was removed from cache`
|
|
4846
4848
|
);
|
|
4847
4849
|
}
|
|
4848
4850
|
/** Removes all files from a hard drive. */
|
|
@@ -4851,7 +4853,7 @@ class rs {
|
|
|
4851
4853
|
Array.from(this.urlToDownload.entries()).map(async ([e, t]) => {
|
|
4852
4854
|
await be(t.path), this.cache.removeCache(t), this.removeTask(
|
|
4853
4855
|
t,
|
|
4854
|
-
`the task ${
|
|
4856
|
+
`the task ${w(t.info())} was released when the driver was closed`
|
|
4855
4857
|
);
|
|
4856
4858
|
})
|
|
4857
4859
|
);
|
|
@@ -4865,7 +4867,7 @@ class rs {
|
|
|
4865
4867
|
}
|
|
4866
4868
|
getFilePath(e) {
|
|
4867
4869
|
const t = It("sha256").update(e.toString()).digest("hex");
|
|
4868
|
-
return
|
|
4870
|
+
return T.join(this.saveDir, t);
|
|
4869
4871
|
}
|
|
4870
4872
|
}
|
|
4871
4873
|
class dr {
|
|
@@ -4903,7 +4905,7 @@ class dr {
|
|
|
4903
4905
|
}
|
|
4904
4906
|
}
|
|
4905
4907
|
async downloadAndUntar(e, t, n) {
|
|
4906
|
-
if (await E(
|
|
4908
|
+
if (await E(T.dirname(this.path)), await F(this.path))
|
|
4907
4909
|
return await pt(this.path);
|
|
4908
4910
|
const o = await e.download(this.url.toString(), {}, n);
|
|
4909
4911
|
let r = o.content;
|
|
@@ -4941,7 +4943,7 @@ async function pt(s) {
|
|
|
4941
4943
|
const e = await m.readdir(s, { withFileTypes: !0 });
|
|
4942
4944
|
return (await Promise.all(
|
|
4943
4945
|
e.map(async (n) => {
|
|
4944
|
-
const o =
|
|
4946
|
+
const o = T.join(s, n.name);
|
|
4945
4947
|
return n.isDirectory() ? await pt(o) : (await m.stat(o)).size;
|
|
4946
4948
|
})
|
|
4947
4949
|
)).reduce((n, o) => n + o, 0);
|
|
@@ -5088,7 +5090,7 @@ class mt {
|
|
|
5088
5090
|
const t = gr(e), n = this.localProjectionsMap.get(t.storageId);
|
|
5089
5091
|
if (!n)
|
|
5090
5092
|
throw new Error(`Storage ${t.storageId} is not mounted locally.`);
|
|
5091
|
-
return
|
|
5093
|
+
return T.join(n.localPath, t.path);
|
|
5092
5094
|
} else {
|
|
5093
5095
|
const t = pr(e);
|
|
5094
5096
|
this.signer.verify(
|
|
@@ -5106,7 +5108,7 @@ class mt {
|
|
|
5106
5108
|
_(e);
|
|
5107
5109
|
for (const n of this.localProjectionsMap.values())
|
|
5108
5110
|
if (e.startsWith(n.localPath)) {
|
|
5109
|
-
const o = n.localPath === "" ? e :
|
|
5111
|
+
const o = n.localPath === "" ? e : T.relative(n.localPath, e);
|
|
5110
5112
|
return ue(
|
|
5111
5113
|
n.storageId,
|
|
5112
5114
|
o
|
|
@@ -5148,11 +5150,11 @@ class mt {
|
|
|
5148
5150
|
handle: ue(n.name, i.fullName)
|
|
5149
5151
|
}))
|
|
5150
5152
|
};
|
|
5151
|
-
|
|
5152
|
-
const o =
|
|
5153
|
+
T.sep === "/" && t === "" && (t = "/"), n.rootPath === "" && _(t);
|
|
5154
|
+
const o = T.isAbsolute(t) ? t : T.join(n.rootPath, t), r = [];
|
|
5153
5155
|
for await (const a of await m.opendir(o)) {
|
|
5154
5156
|
if (!a.isFile() && !a.isDirectory()) continue;
|
|
5155
|
-
const i =
|
|
5157
|
+
const i = T.join(o, a.name);
|
|
5156
5158
|
r.push({
|
|
5157
5159
|
type: a.isFile() ? "file" : "dir",
|
|
5158
5160
|
name: a.name,
|