@camstack/system 1.2.463 → 1.2.464
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/addon-utils.mjs +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -3
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +4 -4
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +4 -4
- package/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +9 -9
- package/dist/builtins/platform-probe/index.mjs +7 -7
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +19 -19
- package/dist/builtins/system-config/system-config.addon.mjs +112 -112
- package/dist/{coral-accelerators-Qhn5TOYZ.mjs → coral-accelerators-D_S1Fo5h.mjs} +5 -5
- package/dist/{custom-action-registry-DZSCLBuT.mjs → custom-action-registry-BGYDjTqY.mjs} +37 -37
- package/dist/index.mjs +219 -219
- package/dist/{restore-archive-CSOR_tyN.mjs → restore-archive-D6sS7Gt2.mjs} +93 -93
- package/package.json +1 -1
package/dist/addon-utils.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as isModelDownloaded, S as isModelDownloadHttpError, _ as downloadFile, a as startEventLoopStallMonitor, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, p as ModelDownloadHttpError, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-
|
|
1
|
+
import { C as isModelDownloaded, S as isModelDownloadHttpError, _ as downloadFile, a as startEventLoopStallMonitor, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, p as ModelDownloadHttpError, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-BGYDjTqY.mjs";
|
|
2
2
|
import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg, t as COURTESY_DEFAULT_WIDTH } from "./snapshot-courtesy-CyFs1M3I.mjs";
|
|
3
3
|
export { COURTESY_DEFAULT_WIDTH, CustomActionRegistry, ModelDownloadHttpError, ModelDownloadService, STALL_REPORT_MS, STALL_TICK_MS, adoptModelRevisions, attributeStall, collectModelFiles, contentTypeFor, courtesyCacheKey, createFileDataPlaneHandler, deleteModelFromDisk, downloadFile, ensureModel, getModelFilePath, isModelDownloadHttpError, isModelDownloaded, parseRangeHeader, renderCourtesyJpeg, renderCourtesyOverlayJpeg, resolveFormatRevision, startEventLoopStallMonitor };
|
|
@@ -2,7 +2,7 @@ import { $r as errMsg, Ca as EventCategory, _t as addonPagesCapability, ei as Ba
|
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
|
-
import * as fs
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
6
|
//#region src/builtins/addon-pages-aggregator/dedupe-pages.ts
|
|
7
7
|
/** Stable identity for an addon page, independent of which node reported it. */
|
|
8
8
|
function pageKey(info) {
|
|
@@ -211,11 +211,11 @@ var AddonPagesAggregatorAddon = class extends BaseAddon {
|
|
|
211
211
|
const bundlePath = this.resolveBundlePath(addonId, bundle);
|
|
212
212
|
if (bundlePath === null) return `/api/addon-pages/${addonId}/${bundle}?v=${Math.floor(Date.now())}`;
|
|
213
213
|
try {
|
|
214
|
-
const stat = fs
|
|
214
|
+
const stat = fs.statSync(bundlePath);
|
|
215
215
|
const cacheKey = `${bundlePath}:${stat.size}:${stat.mtimeMs}`;
|
|
216
216
|
let v = this.bundleHashCache.get(cacheKey);
|
|
217
217
|
if (v === void 0) {
|
|
218
|
-
v = createHash("sha1").update(fs
|
|
218
|
+
v = createHash("sha1").update(fs.readFileSync(bundlePath)).digest("hex").slice(0, 12);
|
|
219
219
|
this.bundleHashCache.set(cacheKey, v);
|
|
220
220
|
}
|
|
221
221
|
return `/api/addon-pages/${addonId}/${bundle}?v=${v}`;
|
|
@@ -2,7 +2,7 @@ import { $r as errMsg, Ca as EventCategory, ei as BaseAddon, yt as addonWidgetsC
|
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
|
-
import * as fs
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
6
|
//#region src/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.ts
|
|
7
7
|
/**
|
|
8
8
|
* Addon Widgets Aggregator — hub-local builtin that owns the singleton
|
|
@@ -204,9 +204,9 @@ var AddonWidgetsAggregatorAddon = class extends BaseAddon {
|
|
|
204
204
|
if (entryPath === null) return String(Math.floor(Date.now()));
|
|
205
205
|
try {
|
|
206
206
|
const dir = path$1.dirname(entryPath);
|
|
207
|
-
const files = fs
|
|
207
|
+
const files = fs.readdirSync(dir).filter((f) => fs.statSync(path$1.join(dir, f)).isFile()).sort();
|
|
208
208
|
const cacheKey = `${dir}#${files.map((f) => {
|
|
209
|
-
const s = fs
|
|
209
|
+
const s = fs.statSync(path$1.join(dir, f));
|
|
210
210
|
return `${f}:${s.size}:${s.mtimeMs}`;
|
|
211
211
|
}).join("|")}`;
|
|
212
212
|
const cached = this.bundleHashCache.get(cacheKey);
|
|
@@ -214,7 +214,7 @@ var AddonWidgetsAggregatorAddon = class extends BaseAddon {
|
|
|
214
214
|
const hash = createHash("sha1");
|
|
215
215
|
for (const f of files) {
|
|
216
216
|
hash.update(f);
|
|
217
|
-
hash.update(fs
|
|
217
|
+
hash.update(fs.readFileSync(path$1.join(dir, f)));
|
|
218
218
|
}
|
|
219
219
|
const digest = hash.digest("hex").slice(0, 12);
|
|
220
220
|
this.bundleHashCache.set(cacheKey, digest);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Ca as EventCategory, Er as storageOccupancyCapability, Tt as backupCapability, Vn as mayWriteToLocation, ei as BaseAddon, ia as nodePin, va as toNodeId } from "../../dist-C2OBCa-A.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
|
-
import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-
|
|
3
|
+
import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-D6sS7Gt2.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import * as fsp from "node:fs/promises";
|
|
6
6
|
import * as path$1 from "node:path";
|
|
7
|
-
import * as fs
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
8
|
//#region src/builtins/backup-orchestrator/backup-databases.ts
|
|
9
9
|
/** Stable id of the seeded weekly schedule. */
|
|
10
10
|
var WEEKLY_SCHEDULE_ID = "weekly-events-history";
|
|
@@ -1018,7 +1018,7 @@ async function downloadArchiveToCache(input) {
|
|
|
1018
1018
|
location: input.locationId,
|
|
1019
1019
|
relativePath: input.filename
|
|
1020
1020
|
});
|
|
1021
|
-
const writeStream = fs
|
|
1021
|
+
const writeStream = fs.createWriteStream(input.cachePath);
|
|
1022
1022
|
let offset = 0;
|
|
1023
1023
|
try {
|
|
1024
1024
|
while (offset < sizeBytes) {
|
|
@@ -2502,7 +2502,7 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
2502
2502
|
});
|
|
2503
2503
|
try {
|
|
2504
2504
|
let offset = 0;
|
|
2505
|
-
const stream = fs
|
|
2505
|
+
const stream = fs.createReadStream(input.cachePath, { highWaterMark: UPLOAD_CHUNK_BYTES });
|
|
2506
2506
|
for await (const rawChunk of stream) {
|
|
2507
2507
|
if (input.signal?.aborted) {
|
|
2508
2508
|
stream.destroy();
|
|
@@ -9,7 +9,7 @@ import * as crypto$1 from "node:crypto";
|
|
|
9
9
|
import { X509Certificate, createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
10
10
|
import nodeCrypto from "crypto";
|
|
11
11
|
import * as path$1 from "node:path";
|
|
12
|
-
import * as fs
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
13
|
//#region src/auth/parse-record.ts
|
|
14
14
|
function parseRecord$2(kind, schema, data) {
|
|
15
15
|
try {
|
|
@@ -12208,8 +12208,8 @@ var LocalAuthAddon = class extends BaseAddon {
|
|
|
12208
12208
|
users: this.userManager,
|
|
12209
12209
|
dataDir: this.ctx.nodeDataDir,
|
|
12210
12210
|
fs: {
|
|
12211
|
-
exists: (filePath) => fs
|
|
12212
|
-
remove: (filePath) => fs
|
|
12211
|
+
exists: (filePath) => fs.existsSync(filePath),
|
|
12212
|
+
remove: (filePath) => fs.rmSync(filePath, { force: true })
|
|
12213
12213
|
},
|
|
12214
12214
|
logger: this.ctx.logger
|
|
12215
12215
|
});
|
|
@@ -3,7 +3,7 @@ import { access, readFile, readdir } from "node:fs/promises";
|
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
import * as os$1 from "node:os";
|
|
5
5
|
import { platform } from "node:os";
|
|
6
|
-
import * as fs
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
7
|
import { constants, readFileSync } from "node:fs";
|
|
8
8
|
import { execFile, execFileSync } from "node:child_process";
|
|
9
9
|
//#region src/builtins/native-metrics/cgroup-memory.ts
|
|
@@ -1642,7 +1642,7 @@ var NativeMetricsProvider = class {
|
|
|
1642
1642
|
let swapUsedBytes = 0;
|
|
1643
1643
|
let swapTotalBytes = 0;
|
|
1644
1644
|
if (IS_LINUX) try {
|
|
1645
|
-
const meminfo = fs
|
|
1645
|
+
const meminfo = fs.readFileSync("/proc/meminfo", "utf-8");
|
|
1646
1646
|
const swapTotal = parseInt(meminfo.match(/SwapTotal:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
|
|
1647
1647
|
const swapFree = parseInt(meminfo.match(/SwapFree:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
|
|
1648
1648
|
swapTotalBytes = swapTotal;
|
|
@@ -1720,7 +1720,7 @@ function sampleMacMemory(provider) {
|
|
|
1720
1720
|
}
|
|
1721
1721
|
function getDiskSpaceInternal(dirPath) {
|
|
1722
1722
|
return new Promise((resolve, reject) => {
|
|
1723
|
-
fs
|
|
1723
|
+
fs.statfs(dirPath, (err, stats) => {
|
|
1724
1724
|
if (err) return reject(err);
|
|
1725
1725
|
const totalBytes = stats.blocks * stats.bsize;
|
|
1726
1726
|
const availableBytes = stats.bavail * stats.bsize;
|
|
@@ -1738,7 +1738,7 @@ function getDiskSpaceInternal(dirPath) {
|
|
|
1738
1738
|
async function takeDiskIoSnapshot() {
|
|
1739
1739
|
const now = Date.now();
|
|
1740
1740
|
if (IS_LINUX) try {
|
|
1741
|
-
const data = fs
|
|
1741
|
+
const data = fs.readFileSync("/proc/diskstats", "utf-8");
|
|
1742
1742
|
let readOps = 0, readBytes = 0, writeOps = 0, writeBytes = 0;
|
|
1743
1743
|
for (const line of data.split("\n")) {
|
|
1744
1744
|
const parts = line.trim().split(/\s+/);
|
|
@@ -1769,7 +1769,7 @@ async function takeDiskIoSnapshot() {
|
|
|
1769
1769
|
async function takeNetworkIoSnapshot() {
|
|
1770
1770
|
const now = Date.now();
|
|
1771
1771
|
if (IS_LINUX) try {
|
|
1772
|
-
const data = fs
|
|
1772
|
+
const data = fs.readFileSync("/proc/net/dev", "utf-8");
|
|
1773
1773
|
let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
|
|
1774
1774
|
for (const line of data.split("\n")) {
|
|
1775
1775
|
const match = line.match(/^\s*(\w+):\s+(.+)$/);
|
|
@@ -1830,7 +1830,7 @@ async function takeNetworkIoSnapshot() {
|
|
|
1830
1830
|
}
|
|
1831
1831
|
async function getCpuTemperatureInternal() {
|
|
1832
1832
|
if (IS_LINUX) for (const p of ["/sys/class/thermal/thermal_zone0/temp", "/sys/class/hwmon/hwmon0/temp1_input"]) try {
|
|
1833
|
-
const raw = fs
|
|
1833
|
+
const raw = fs.readFileSync(p, "utf-8").trim();
|
|
1834
1834
|
const millideg = parseInt(raw, 10);
|
|
1835
1835
|
if (!isNaN(millideg)) return Math.round(millideg / 100) / 10;
|
|
1836
1836
|
} catch {
|
|
@@ -1881,10 +1881,10 @@ function getProcessResources() {
|
|
|
1881
1881
|
let threadCount = 0;
|
|
1882
1882
|
if (IS_LINUX) {
|
|
1883
1883
|
try {
|
|
1884
|
-
openFds = fs
|
|
1884
|
+
openFds = fs.readdirSync(`/proc/${process.pid}/fd`).length;
|
|
1885
1885
|
} catch {}
|
|
1886
1886
|
try {
|
|
1887
|
-
const match = fs
|
|
1887
|
+
const match = fs.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
|
|
1888
1888
|
if (match) threadCount = parseInt(match[1], 10);
|
|
1889
1889
|
} catch {}
|
|
1890
1890
|
}
|
|
@@ -1899,7 +1899,7 @@ function getProcessResources() {
|
|
|
1899
1899
|
function getPressure(resource) {
|
|
1900
1900
|
if (!IS_LINUX) return null;
|
|
1901
1901
|
try {
|
|
1902
|
-
const data = fs
|
|
1902
|
+
const data = fs.readFileSync(`/proc/pressure/${resource}`, "utf-8");
|
|
1903
1903
|
const parseLine = (prefix) => {
|
|
1904
1904
|
const match = data.match(new RegExp(`${prefix} avg10=(\\d+\\.\\d+) avg60=(\\d+\\.\\d+) avg300=(\\d+\\.\\d+)`));
|
|
1905
1905
|
if (!match) return null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
2
|
import { $n as platformProbeCapability, $r as errMsg, Ca as EventCategory, Gi as emitReadiness, _r as scoreRuntimes, an as enumerateInferenceDevices, ei as BaseAddon } from "../../dist-C2OBCa-A.mjs";
|
|
3
|
-
import { n as nodeCoralFs, t as classifyCoralAccelerator } from "../../coral-accelerators-
|
|
3
|
+
import { n as nodeCoralFs, t as classifyCoralAccelerator } from "../../coral-accelerators-D_S1Fo5h.mjs";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import * as os$1 from "node:os";
|
|
6
|
-
import * as fs
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
7
|
import { execFile } from "node:child_process";
|
|
8
8
|
//#region src/builtins/platform-probe/amd-npu.ts
|
|
9
9
|
var amd_npu_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -448,14 +448,14 @@ var PlatformScorer = class {
|
|
|
448
448
|
if (nvidia) gpu = nvidia;
|
|
449
449
|
const listRenderNodes = () => {
|
|
450
450
|
try {
|
|
451
|
-
return fs
|
|
451
|
+
return fs.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
|
|
452
452
|
} catch {
|
|
453
453
|
return [];
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
456
|
const readDrmAttr = (node, attr) => {
|
|
457
457
|
try {
|
|
458
|
-
return fs
|
|
458
|
+
return fs.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
|
|
459
459
|
} catch {
|
|
460
460
|
return "";
|
|
461
461
|
}
|
|
@@ -481,12 +481,12 @@ var PlatformScorer = class {
|
|
|
481
481
|
}
|
|
482
482
|
const listDir = (p) => {
|
|
483
483
|
try {
|
|
484
|
-
return fs
|
|
484
|
+
return fs.readdirSync(p);
|
|
485
485
|
} catch {
|
|
486
486
|
return [];
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
|
-
const exists = (p) => fs
|
|
489
|
+
const exists = (p) => fs.existsSync(p);
|
|
490
490
|
if (!npu) {
|
|
491
491
|
const { classifyIntelNpu } = await import("../../intel-npu-C8HKvRQF.mjs");
|
|
492
492
|
npu = classifyIntelNpu({
|
|
@@ -514,7 +514,7 @@ var PlatformScorer = class {
|
|
|
514
514
|
exists,
|
|
515
515
|
readFile: (p) => {
|
|
516
516
|
try {
|
|
517
|
-
return fs
|
|
517
|
+
return fs.readFileSync(p, "utf8");
|
|
518
518
|
} catch {
|
|
519
519
|
return "";
|
|
520
520
|
}
|
|
@@ -4,7 +4,7 @@ import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
|
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
|
-
import * as fs
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
8
|
//#region src/builtins/sqlite-storage/path-guard.ts
|
|
9
9
|
/**
|
|
10
10
|
* Guards for the filesystem-browse cap. Pure + synchronous so they are
|
|
@@ -169,16 +169,16 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
169
169
|
error: "config.basePath must be a non-empty string"
|
|
170
170
|
};
|
|
171
171
|
try {
|
|
172
|
-
const stat = await fs
|
|
172
|
+
const stat = await fs.promises.stat(basePath).catch(() => null);
|
|
173
173
|
if (stat) {
|
|
174
174
|
if (!stat.isDirectory()) return {
|
|
175
175
|
ok: false,
|
|
176
176
|
error: `Path "${basePath}" exists but is not a directory`
|
|
177
177
|
};
|
|
178
|
-
await fs
|
|
178
|
+
await fs.promises.access(basePath, fs.constants.W_OK);
|
|
179
179
|
return { ok: true };
|
|
180
180
|
}
|
|
181
|
-
await fs
|
|
181
|
+
await fs.promises.mkdir(basePath, { recursive: true });
|
|
182
182
|
return { ok: true };
|
|
183
183
|
} catch (err) {
|
|
184
184
|
return {
|
|
@@ -192,12 +192,12 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
192
192
|
}
|
|
193
193
|
async write({ location, relativePath, data }) {
|
|
194
194
|
const filePath = safeResolve(getBasePath(location), relativePath);
|
|
195
|
-
await fs
|
|
196
|
-
await fs
|
|
195
|
+
await fs.promises.mkdir(path$1.dirname(filePath), { recursive: true });
|
|
196
|
+
await fs.promises.writeFile(filePath, data);
|
|
197
197
|
}
|
|
198
198
|
async read({ location, relativePath }) {
|
|
199
199
|
const filePath = safeResolve(getBasePath(location), relativePath);
|
|
200
|
-
const buf = await fs
|
|
200
|
+
const buf = await fs.promises.readFile(filePath);
|
|
201
201
|
const out = new Uint8Array(new ArrayBuffer(buf.byteLength));
|
|
202
202
|
out.set(buf);
|
|
203
203
|
return out;
|
|
@@ -205,7 +205,7 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
205
205
|
async exists({ location, relativePath }) {
|
|
206
206
|
const filePath = safeResolve(getBasePath(location), relativePath);
|
|
207
207
|
try {
|
|
208
|
-
await fs
|
|
208
|
+
await fs.promises.access(filePath);
|
|
209
209
|
return true;
|
|
210
210
|
} catch {
|
|
211
211
|
return false;
|
|
@@ -215,25 +215,25 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
215
215
|
const base = getBasePath(location);
|
|
216
216
|
const dir = prefix ? safeResolve(base, prefix) : path$1.resolve(base);
|
|
217
217
|
try {
|
|
218
|
-
return (await fs
|
|
218
|
+
return (await fs.promises.readdir(dir, { withFileTypes: true })).map((e) => prefix ? `${prefix}/${e.name}` : e.name);
|
|
219
219
|
} catch {
|
|
220
220
|
return [];
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
async delete({ location, relativePath }) {
|
|
224
224
|
const filePath = safeResolve(getBasePath(location), relativePath);
|
|
225
|
-
await fs
|
|
225
|
+
await fs.promises.rm(filePath, { force: true });
|
|
226
226
|
}
|
|
227
227
|
async getAvailableSpace({ location }) {
|
|
228
228
|
const base = path$1.resolve(getBasePath(location));
|
|
229
229
|
try {
|
|
230
230
|
let target = base;
|
|
231
|
-
while (!fs
|
|
231
|
+
while (!fs.existsSync(target)) {
|
|
232
232
|
const parent = path$1.dirname(target);
|
|
233
233
|
if (!parent || parent === target) return null;
|
|
234
234
|
target = parent;
|
|
235
235
|
}
|
|
236
|
-
const stats = await fs
|
|
236
|
+
const stats = await fs.promises.statfs(target);
|
|
237
237
|
return stats.bavail * stats.bsize;
|
|
238
238
|
} catch {
|
|
239
239
|
return null;
|
|
@@ -242,9 +242,9 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
242
242
|
async beginUpload({ location, relativePath }) {
|
|
243
243
|
const target = safeResolve(getBasePath(location), relativePath);
|
|
244
244
|
const partial = `${target}.partial`;
|
|
245
|
-
await fs
|
|
246
|
-
await fs
|
|
247
|
-
const stream = fs
|
|
245
|
+
await fs.promises.mkdir(path$1.dirname(target), { recursive: true });
|
|
246
|
+
await fs.promises.unlink(partial).catch(() => {});
|
|
247
|
+
const stream = fs.createWriteStream(partial);
|
|
248
248
|
const uploadId = randomUUID();
|
|
249
249
|
const session = {
|
|
250
250
|
stream,
|
|
@@ -285,7 +285,7 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
285
285
|
session.stream.end(() => resolve());
|
|
286
286
|
session.stream.on("error", reject);
|
|
287
287
|
});
|
|
288
|
-
await fs
|
|
288
|
+
await fs.promises.rename(session.partial, session.target);
|
|
289
289
|
clearTimeout(session.timer);
|
|
290
290
|
this.uploads.delete(uploadId);
|
|
291
291
|
}
|
|
@@ -295,14 +295,14 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
295
295
|
try {
|
|
296
296
|
session.stream.destroy();
|
|
297
297
|
} catch {}
|
|
298
|
-
await fs
|
|
298
|
+
await fs.promises.unlink(session.partial).catch(() => {});
|
|
299
299
|
clearTimeout(session.timer);
|
|
300
300
|
this.uploads.delete(uploadId);
|
|
301
301
|
}
|
|
302
302
|
async beginDownload({ location, relativePath }) {
|
|
303
303
|
const target = safeResolve(getBasePath(location), relativePath);
|
|
304
|
-
const stat = await fs
|
|
305
|
-
const fd = await fs
|
|
304
|
+
const stat = await fs.promises.stat(target);
|
|
305
|
+
const fd = await fs.promises.open(target, "r");
|
|
306
306
|
const downloadId = randomUUID();
|
|
307
307
|
const session = {
|
|
308
308
|
fd,
|