@ai-ecoverse/slicc-kernel 1.196.32 → 1.196.33
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/README.md +1 -1
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +263 -85
- package/dist/cloudflare.js.map +4 -4
- package/dist/kernel-worker.js +260 -85
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +260 -85
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +4 -0
- package/dist/types/fs/opfs.d.ts +11 -1
- package/dist/types/fs/rename-cleanup.d.ts +12 -0
- package/package.json +1 -1
package/dist/cloudflare.js
CHANGED
|
@@ -5273,7 +5273,7 @@ function satisfies(version, range2) {
|
|
|
5273
5273
|
}
|
|
5274
5274
|
|
|
5275
5275
|
// src/version.ts
|
|
5276
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
5276
|
+
var KERNEL_VERSION = true ? "1.196.33" : "0.0.0-dev";
|
|
5277
5277
|
var OS_RELEASE = "6.0.0-slicc";
|
|
5278
5278
|
function procVersion() {
|
|
5279
5279
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8763,14 +8763,14 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
8763
8763
|
}
|
|
8764
8764
|
return target?.path;
|
|
8765
8765
|
}
|
|
8766
|
-
const
|
|
8766
|
+
const absent3 = (err) => {
|
|
8767
8767
|
if (missing2(err)) return EMPTY2;
|
|
8768
8768
|
throw err;
|
|
8769
8769
|
};
|
|
8770
8770
|
async function content(path, err) {
|
|
8771
8771
|
if (!missing2(err) || !(await linked2(path))?.isFile) throw err;
|
|
8772
8772
|
const target = await redirected2(path);
|
|
8773
|
-
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(
|
|
8773
|
+
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(absent3);
|
|
8774
8774
|
}
|
|
8775
8775
|
const ranged2 = rangedOps(fs);
|
|
8776
8776
|
async function stat(path, real2) {
|
|
@@ -8847,7 +8847,7 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
8847
8847
|
pread: (path, offset, length2, version) => ranged2.pread(path, offset, length2, version).catch(async (err) => {
|
|
8848
8848
|
const target = missing2(err) ? await redirected2(path) : void 0;
|
|
8849
8849
|
if (target === void 0) throw err;
|
|
8850
|
-
return ranged2.pread(target, offset, length2).catch(
|
|
8850
|
+
return ranged2.pread(target, offset, length2).catch(absent3);
|
|
8851
8851
|
})
|
|
8852
8852
|
} : {}
|
|
8853
8853
|
};
|
|
@@ -8936,9 +8936,9 @@ function withEtcFiles(fs, files) {
|
|
|
8936
8936
|
const text = files.get(path)?.();
|
|
8937
8937
|
return text === void 0 ? void 0 : new TextEncoder().encode(text);
|
|
8938
8938
|
};
|
|
8939
|
-
const
|
|
8939
|
+
const absent3 = (path) => fs.lstat(path).then(() => false, missing3);
|
|
8940
8940
|
const follow2 = linkFollower(fs, files);
|
|
8941
|
-
const listedAbsent = async (path) => files.has(path) && await
|
|
8941
|
+
const listedAbsent = async (path) => files.has(path) && await absent3(path) ? bytesOf7(path) : void 0;
|
|
8942
8942
|
const fallback = (path, make) => async (err) => {
|
|
8943
8943
|
const at = missing3(err) ? await follow2(path) : void 0;
|
|
8944
8944
|
const bytes = at === void 0 ? void 0 : await listedAbsent(at);
|
|
@@ -8950,10 +8950,10 @@ function withEtcFiles(fs, files) {
|
|
|
8950
8950
|
const own = {
|
|
8951
8951
|
stat: (path) => fs.stat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
8952
8952
|
lstat: (path) => fs.lstat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
8953
|
-
exists: async (path) => await fs.exists(path) || files.has(path) && await
|
|
8953
|
+
exists: async (path) => await fs.exists(path) || files.has(path) && await absent3(path),
|
|
8954
8954
|
...fs.createExclusive ? {
|
|
8955
8955
|
createExclusive: async (path, owner) => {
|
|
8956
|
-
if (files.has(path) && await
|
|
8956
|
+
if (files.has(path) && await absent3(path)) throw fsError("EEXIST", path);
|
|
8957
8957
|
return fs.createExclusive.call(
|
|
8958
8958
|
fs,
|
|
8959
8959
|
path,
|
|
@@ -10156,11 +10156,11 @@ var FsWatchers = class {
|
|
|
10156
10156
|
}
|
|
10157
10157
|
},
|
|
10158
10158
|
rm: reshaping(async (path, options) => {
|
|
10159
|
-
const
|
|
10159
|
+
const absent3 = options?.force === true && await fs.lstat(path).then(
|
|
10160
10160
|
() => false,
|
|
10161
10161
|
() => true
|
|
10162
10162
|
);
|
|
10163
|
-
if (
|
|
10163
|
+
if (absent3) return fs.rm(path, options);
|
|
10164
10164
|
const retire = await retiring?.(path);
|
|
10165
10165
|
await removing(path, options);
|
|
10166
10166
|
await retire?.();
|
|
@@ -15265,8 +15265,8 @@ var DEV_PROBES = /* @__PURE__ */ new Set([
|
|
|
15265
15265
|
]);
|
|
15266
15266
|
async function devsOf(entry, req, result) {
|
|
15267
15267
|
if (req.devs !== true || !DEV_PROBES.has(req.op)) return result;
|
|
15268
|
-
const
|
|
15269
|
-
if (!
|
|
15268
|
+
const absent3 = result.ok ? result.kind === "json" && result.json === false : result.errno === "ENOENT";
|
|
15269
|
+
if (!absent3) return result;
|
|
15270
15270
|
const dev = await devTarget(entry, req, entry.fs.resolvePath(entry.cwd, req.path));
|
|
15271
15271
|
if (dev === void 0) return result;
|
|
15272
15272
|
return result.ok ? json2({ dev }) : { ...result, dev };
|
|
@@ -33624,6 +33624,44 @@ var PrivateRename = class {
|
|
|
33624
33624
|
}
|
|
33625
33625
|
};
|
|
33626
33626
|
|
|
33627
|
+
// src/fs/rename-cleanup.ts
|
|
33628
|
+
function cleanupId(handle) {
|
|
33629
|
+
return handle.getUniqueId?.();
|
|
33630
|
+
}
|
|
33631
|
+
async function copiedEntry(handle, path, file) {
|
|
33632
|
+
const id2 = await cleanupId(handle);
|
|
33633
|
+
return {
|
|
33634
|
+
path,
|
|
33635
|
+
kind: handle.kind,
|
|
33636
|
+
...id2 !== void 0 && { id: id2 },
|
|
33637
|
+
...file && { size: file.size, mtime: file.lastModified }
|
|
33638
|
+
};
|
|
33639
|
+
}
|
|
33640
|
+
function absent(err) {
|
|
33641
|
+
return err.name === "NotFoundError";
|
|
33642
|
+
}
|
|
33643
|
+
async function removeOne(parent, name2, rest2, entries) {
|
|
33644
|
+
const entry = entries.get(rest2);
|
|
33645
|
+
if (!entry) return;
|
|
33646
|
+
try {
|
|
33647
|
+
const handle = entry.kind === "file" ? await parent.getFileHandle(name2) : await parent.getDirectoryHandle(name2);
|
|
33648
|
+
if (entry.id !== void 0 && await cleanupId(handle) !== entry.id) return;
|
|
33649
|
+
if (handle.kind === "file") {
|
|
33650
|
+
const file = await handle.getFile();
|
|
33651
|
+
if (file.lastModified !== entry.mtime || file.size !== entry.size) return;
|
|
33652
|
+
} else {
|
|
33653
|
+
for await (const child2 of handle.keys())
|
|
33654
|
+
await removeOne(handle, child2, rest2 + "/" + child2, entries);
|
|
33655
|
+
}
|
|
33656
|
+
await parent.removeEntry(name2);
|
|
33657
|
+
} catch (err) {
|
|
33658
|
+
if (!absent(err) && err.name !== "TypeMismatchError") throw err;
|
|
33659
|
+
}
|
|
33660
|
+
}
|
|
33661
|
+
function removeCopied(parent, name2, manifest) {
|
|
33662
|
+
return removeOne(parent, name2, "", new Map(manifest.map((entry) => [entry.path, entry])));
|
|
33663
|
+
}
|
|
33664
|
+
|
|
33627
33665
|
// src/fs/opfs.ts
|
|
33628
33666
|
var S_IFDIR2 = 16384;
|
|
33629
33667
|
var S_IFREG3 = 32768;
|
|
@@ -33668,6 +33706,9 @@ var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
|
33668
33706
|
var PRIVATE_NATIVE = /* @__PURE__ */ Symbol("private-native");
|
|
33669
33707
|
var ACK_SAMPLES = 4096;
|
|
33670
33708
|
var INTENT_POLL_MS = 5;
|
|
33709
|
+
var Copies = class extends Map {
|
|
33710
|
+
remaining = [];
|
|
33711
|
+
};
|
|
33671
33712
|
function needsCopy(handle, swap) {
|
|
33672
33713
|
return swap || handle.kind === "directory" && !movable(handle);
|
|
33673
33714
|
}
|
|
@@ -34184,6 +34225,7 @@ var OpfsFs = class {
|
|
|
34184
34225
|
return view(this, { rejectLinks: true });
|
|
34185
34226
|
}
|
|
34186
34227
|
refuse(path, holding = false) {
|
|
34228
|
+
this.reserveWrite(path, holding);
|
|
34187
34229
|
if (isProtected(this.guarded, path) || holding && holdsProtected(this.guarded, path)) {
|
|
34188
34230
|
throw fsError("EROFS", path);
|
|
34189
34231
|
}
|
|
@@ -34395,6 +34437,7 @@ var OpfsFs = class {
|
|
|
34395
34437
|
return this.lookups - seen.op < lookups && performance.now() - seen.at < GLANCE_CAP_MS;
|
|
34396
34438
|
}
|
|
34397
34439
|
async handle(path) {
|
|
34440
|
+
if (this.sourceReservation(path)) throw fsError("ENOENT", path);
|
|
34398
34441
|
this.lookups++;
|
|
34399
34442
|
if (split2(path).length === 0) return this.root;
|
|
34400
34443
|
const cached = this.files.get(path);
|
|
@@ -35078,6 +35121,9 @@ var OpfsFs = class {
|
|
|
35078
35121
|
const name2 = baseOf4(link2.path);
|
|
35079
35122
|
if (!children3.has(name2)) children3.set(name2, link2);
|
|
35080
35123
|
}
|
|
35124
|
+
for (const source of this.pendingSources.values()) {
|
|
35125
|
+
if (parentOf11(source) === found.path) children3.delete(baseOf4(source));
|
|
35126
|
+
}
|
|
35081
35127
|
for (const backup of this.hiddenBackups) {
|
|
35082
35128
|
if (parentOf11(backup) === found.path) children3.delete(baseOf4(backup));
|
|
35083
35129
|
}
|
|
@@ -35257,7 +35303,7 @@ var OpfsFs = class {
|
|
|
35257
35303
|
);
|
|
35258
35304
|
}
|
|
35259
35305
|
async removalParentId(path) {
|
|
35260
|
-
const parent = await
|
|
35306
|
+
const parent = await PLAIN3.lstat.call(this, parentOf11(path));
|
|
35261
35307
|
return parent.isDirectory ? `${parent.dev ?? 0}:${parent.ino}` : void 0;
|
|
35262
35308
|
}
|
|
35263
35309
|
async removePhysical(path, recursive) {
|
|
@@ -35416,7 +35462,7 @@ var OpfsFs = class {
|
|
|
35416
35462
|
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
35417
35463
|
const place = async () => {
|
|
35418
35464
|
this.forget(destination);
|
|
35419
|
-
const copies =
|
|
35465
|
+
const copies = new Copies();
|
|
35420
35466
|
const root = { ino: inodeOf(source.path), ...moving };
|
|
35421
35467
|
const owned4 = lock ? { lock } : {};
|
|
35422
35468
|
hooks.notify?.();
|
|
@@ -35435,18 +35481,23 @@ var OpfsFs = class {
|
|
|
35435
35481
|
if (first) await this.rollBack(staged2, source.path, [first, second]);
|
|
35436
35482
|
throw err;
|
|
35437
35483
|
});
|
|
35438
|
-
if (swap) await
|
|
35484
|
+
if (swap) await PLAIN3.rm.call(this, destination);
|
|
35439
35485
|
if (second) await this.intend({ from: staged2, to: destination, root, ...owned4 }, second);
|
|
35440
35486
|
await this.meta.move(source.path, destination, carry, left);
|
|
35441
35487
|
this.movePending(source.path, destination);
|
|
35442
|
-
if (!moved3
|
|
35443
|
-
|
|
35488
|
+
if (!moved3 && first)
|
|
35489
|
+
await this.releaseSource(first, source.path, destination, left.ino, lock, copies.remaining);
|
|
35490
|
+
else if (first) await this.meta.update(first, () => void 0);
|
|
35444
35491
|
if (swap) {
|
|
35445
35492
|
const hidden = await dir.getDirectoryHandle(staging);
|
|
35493
|
+
copies.remaining = [];
|
|
35446
35494
|
const placed = await this.place(hidden, dir, name2, copies, copying);
|
|
35447
|
-
if (!placed
|
|
35495
|
+
if (!placed && second) {
|
|
35496
|
+
const mark = vacatedAt(staged2);
|
|
35497
|
+
await this.meta.update(staged2, () => mark);
|
|
35498
|
+
await this.releaseSource(second, staged2, destination, mark.ino, lock, copies.remaining);
|
|
35499
|
+
} else if (second) await this.meta.update(second, () => void 0);
|
|
35448
35500
|
}
|
|
35449
|
-
if (second) await this.meta.update(second, () => void 0);
|
|
35450
35501
|
await this.restamp(destination, copies);
|
|
35451
35502
|
this.changed(source.path, destination);
|
|
35452
35503
|
this.touch(Date.now(), parentOf11(source.path), parent.path);
|
|
@@ -35665,6 +35716,10 @@ var OpfsFs = class {
|
|
|
35665
35716
|
const left = (await this.meta.under(RENAMES2)).filter((entry) => entry.rename?.lock === move.lock).sort(byIntent);
|
|
35666
35717
|
for (const entry of left) await this.finishRename(entry);
|
|
35667
35718
|
});
|
|
35719
|
+
for (const entry of await this.meta.under(RENAMES2)) {
|
|
35720
|
+
if (entry.rename?.lock === move.lock && entry.rename.sourceCleanup !== void 0)
|
|
35721
|
+
this.syncSourceReservation(entry.path, entry.rename.from);
|
|
35722
|
+
}
|
|
35668
35723
|
this.peerMoves.delete(move.lock);
|
|
35669
35724
|
for (const [from, to] of move.trees) {
|
|
35670
35725
|
this.forget(from);
|
|
@@ -35692,9 +35747,10 @@ var OpfsFs = class {
|
|
|
35692
35747
|
}
|
|
35693
35748
|
aloneCalls = 0;
|
|
35694
35749
|
aloneDrain;
|
|
35695
|
-
async alonePlain(inner, args) {
|
|
35750
|
+
async alonePlain(name2, inner, args) {
|
|
35696
35751
|
this.aloneCalls++;
|
|
35697
35752
|
try {
|
|
35753
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
35698
35754
|
return await inner.apply(this, args);
|
|
35699
35755
|
} finally {
|
|
35700
35756
|
this.aloneCalls--;
|
|
@@ -35725,6 +35781,7 @@ var OpfsFs = class {
|
|
|
35725
35781
|
for (const at of paths) checked.push(...await this.peerSettled(at, listing, removing));
|
|
35726
35782
|
if (!checked.some((at) => this.peerAt(at, listing, removing))) break;
|
|
35727
35783
|
}
|
|
35784
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
35728
35785
|
const busy = { paths: checked, removing, release: () => void 0 };
|
|
35729
35786
|
const done4 = () => {
|
|
35730
35787
|
this.inflight.delete(busy);
|
|
@@ -35755,6 +35812,7 @@ var OpfsFs = class {
|
|
|
35755
35812
|
let sessionOwnsAdmission = false;
|
|
35756
35813
|
let native = false;
|
|
35757
35814
|
try {
|
|
35815
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
35758
35816
|
if (name2 === "writeSession") {
|
|
35759
35817
|
const session = await inner.apply(inside2, args);
|
|
35760
35818
|
sessionOwnsAdmission = true;
|
|
@@ -35813,7 +35871,7 @@ var OpfsFs = class {
|
|
|
35813
35871
|
const handle = source.handle;
|
|
35814
35872
|
const dir = parent.handle;
|
|
35815
35873
|
const name2 = baseOf4(to);
|
|
35816
|
-
const copies =
|
|
35874
|
+
const copies = new Copies();
|
|
35817
35875
|
const [entry] = await this.meta.get([source.path]);
|
|
35818
35876
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
35819
35877
|
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
@@ -35866,16 +35924,19 @@ var OpfsFs = class {
|
|
|
35866
35924
|
async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
|
|
35867
35925
|
const { ino, ...owner } = root;
|
|
35868
35926
|
const entries = await this.meta.get([from, to]);
|
|
35869
|
-
|
|
35927
|
+
let mark = entries[0];
|
|
35928
|
+
if (!mark?.vacated || entries[1]?.ino !== ino) {
|
|
35929
|
+
mark = vacatedAt(from);
|
|
35870
35930
|
await this.meta.move(
|
|
35871
35931
|
from,
|
|
35872
35932
|
to,
|
|
35873
35933
|
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
35874
|
-
|
|
35934
|
+
mark
|
|
35875
35935
|
);
|
|
35876
35936
|
}
|
|
35937
|
+
if (!emptyBackup)
|
|
35938
|
+
await this.releaseSource(intent, from, to, mark.ino, void 0, copies.remaining);
|
|
35877
35939
|
this.movePending(from, to);
|
|
35878
|
-
if (!emptyBackup) await this.removePhysical(from, true);
|
|
35879
35940
|
await this.restamp(to, copies);
|
|
35880
35941
|
this.changed(from, to);
|
|
35881
35942
|
this.touch(Date.now(), parentOf11(from), parentOf11(to));
|
|
@@ -35883,16 +35944,102 @@ var OpfsFs = class {
|
|
|
35883
35944
|
await this.intend({ from, to, root, emptyBackup, cleanupOnly: true }, intent);
|
|
35884
35945
|
return this.cleanSwapIntent(intent, emptyBackup);
|
|
35885
35946
|
}
|
|
35886
|
-
|
|
35947
|
+
}
|
|
35948
|
+
async sourceId(path) {
|
|
35949
|
+
const [dir, name2] = await this.parent(path);
|
|
35950
|
+
const parent = await this.dir(dir);
|
|
35951
|
+
let handle;
|
|
35952
|
+
try {
|
|
35953
|
+
handle = await this.child(parent, name2, "directory");
|
|
35954
|
+
} catch (err) {
|
|
35955
|
+
if (err.name !== "TypeMismatchError") throw err;
|
|
35956
|
+
handle = await this.child(parent, name2, "file");
|
|
35957
|
+
}
|
|
35958
|
+
return cleanupId(handle);
|
|
35959
|
+
}
|
|
35960
|
+
async releaseSource(intent, from, to, id2, lock, copiedEntries) {
|
|
35961
|
+
this.syncSourceReservation(intent, from);
|
|
35962
|
+
const physicalSource = copiedEntries?.find((entry) => entry.path === "")?.id;
|
|
35963
|
+
await this.intend(
|
|
35964
|
+
{
|
|
35965
|
+
from,
|
|
35966
|
+
to,
|
|
35967
|
+
sourceCleanup: id2,
|
|
35968
|
+
...lock && { lock },
|
|
35969
|
+
...physicalSource && { physicalSource },
|
|
35970
|
+
...copiedEntries && { copiedEntries }
|
|
35971
|
+
},
|
|
35972
|
+
intent
|
|
35973
|
+
);
|
|
35974
|
+
await this.cleanSource(intent, from, id2);
|
|
35975
|
+
}
|
|
35976
|
+
async cleanSource(intent, from, id2) {
|
|
35977
|
+
const remove = async () => {
|
|
35978
|
+
const [current] = await this.meta.under(intent);
|
|
35979
|
+
if (current?.rename?.sourceCleanup === id2) {
|
|
35980
|
+
const [reservation] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [from]);
|
|
35981
|
+
if (reservation?.vacated && reservation.ino === id2) {
|
|
35982
|
+
try {
|
|
35983
|
+
const expected = current.rename.physicalSource;
|
|
35984
|
+
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
35985
|
+
const [dir, name2] = await this.parent(from);
|
|
35986
|
+
await this.inDir(
|
|
35987
|
+
dir,
|
|
35988
|
+
(parent) => current.rename?.copiedEntries ? removeCopied(parent, name2, current.rename.copiedEntries) : parent.removeEntry(name2)
|
|
35989
|
+
);
|
|
35990
|
+
}
|
|
35991
|
+
} catch (err) {
|
|
35992
|
+
if (!missing5(err) && err.name !== "NotFoundError") return;
|
|
35993
|
+
}
|
|
35994
|
+
await this.meta.update(
|
|
35995
|
+
from,
|
|
35996
|
+
(current2) => current2?.vacated && current2.ino === reservation.ino ? vacatedAt(from) : current2
|
|
35997
|
+
);
|
|
35998
|
+
}
|
|
35999
|
+
await this.meta.update(intent, () => void 0);
|
|
36000
|
+
}
|
|
36001
|
+
this.syncSourceReservation(intent);
|
|
36002
|
+
};
|
|
36003
|
+
this.syncSourceReservation(intent, from);
|
|
36004
|
+
if (this.locks) await this.locks.request(this.lockPrefix + intent, remove);
|
|
36005
|
+
else await remove();
|
|
35887
36006
|
}
|
|
35888
36007
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
35889
36008
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
36009
|
+
copies.remaining.push(await copiedEntry(handle, rest2));
|
|
35890
36010
|
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
35891
36011
|
this.others++;
|
|
35892
36012
|
for await (const child2 of handle.values())
|
|
35893
36013
|
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
35894
36014
|
}
|
|
35895
36015
|
hiddenBackups = /* @__PURE__ */ new Set();
|
|
36016
|
+
pendingSources = /* @__PURE__ */ new Map();
|
|
36017
|
+
syncSourceReservation(intent, from) {
|
|
36018
|
+
const path = from ?? this.pendingSources.get(intent);
|
|
36019
|
+
if (from === void 0) this.pendingSources.delete(intent);
|
|
36020
|
+
else this.pendingSources.set(intent, from);
|
|
36021
|
+
if (path) this.forget(path);
|
|
36022
|
+
}
|
|
36023
|
+
async reservedOp(name2, args) {
|
|
36024
|
+
const touched = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
36025
|
+
for (const [intent, source] of this.pendingSources) {
|
|
36026
|
+
const [entry] = await this.meta.under(intent);
|
|
36027
|
+
if (entry?.rename?.sourceCleanup === void 0) this.syncSourceReservation(intent);
|
|
36028
|
+
else if (!READS.includes(name2) && touched.some((p) => {
|
|
36029
|
+
const at = normalizePath(p);
|
|
36030
|
+
return within11(at, source) || REMOVALS2.has(name2) && (at === "/" || within11(source, at));
|
|
36031
|
+
}))
|
|
36032
|
+
throw fsError("EBUSY", source);
|
|
36033
|
+
}
|
|
36034
|
+
}
|
|
36035
|
+
sourceReservation(path, ancestor = false) {
|
|
36036
|
+
for (const source of this.pendingSources.values())
|
|
36037
|
+
if (within11(path, source) || ancestor && within11(source, path)) return source;
|
|
36038
|
+
return void 0;
|
|
36039
|
+
}
|
|
36040
|
+
reserveWrite(path, ancestor = false) {
|
|
36041
|
+
if (this.sourceReservation(path, ancestor)) throw fsError("EBUSY", path);
|
|
36042
|
+
}
|
|
35896
36043
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
35897
36044
|
intents = 0;
|
|
35898
36045
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -35953,7 +36100,7 @@ var OpfsFs = class {
|
|
|
35953
36100
|
}
|
|
35954
36101
|
if (!left) {
|
|
35955
36102
|
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
35956
|
-
return this.commitPrivateCopy(from, to, root, intent,
|
|
36103
|
+
return this.commitPrivateCopy(from, to, root, intent, new Copies(), backup);
|
|
35957
36104
|
}
|
|
35958
36105
|
const staged2 = await this.swapEntry(backup);
|
|
35959
36106
|
if (staged2) {
|
|
@@ -35966,10 +36113,72 @@ var OpfsFs = class {
|
|
|
35966
36113
|
}
|
|
35967
36114
|
await this.dropSwapIntent(intent, backup);
|
|
35968
36115
|
}
|
|
36116
|
+
async resumeCopiedTree(intent, rename) {
|
|
36117
|
+
const { from, to, root } = rename;
|
|
36118
|
+
const left = await this.real(from);
|
|
36119
|
+
if (left && root) {
|
|
36120
|
+
const [mark, placed] = await this.meta.get([from, to]);
|
|
36121
|
+
if (mark?.vacated && mark.ino !== void 0 && placed?.ino === root.ino)
|
|
36122
|
+
return this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36123
|
+
}
|
|
36124
|
+
if (rename.privateCopy) {
|
|
36125
|
+
if (left) {
|
|
36126
|
+
const src = await this.locate(from, false);
|
|
36127
|
+
const dir = await this.locate(parentOf11(to), true);
|
|
36128
|
+
const copies = new Copies();
|
|
36129
|
+
await this.duplicate(
|
|
36130
|
+
src.handle,
|
|
36131
|
+
dir.handle,
|
|
36132
|
+
baseOf4(to),
|
|
36133
|
+
copies,
|
|
36134
|
+
""
|
|
36135
|
+
);
|
|
36136
|
+
await this.commitPrivateCopy(from, to, root ?? { ino: inodeOf(from) }, intent, copies);
|
|
36137
|
+
} else await this.meta.update(intent, () => void 0);
|
|
36138
|
+
return;
|
|
36139
|
+
}
|
|
36140
|
+
await this.resumeCoordinatedCopy(intent, rename, left);
|
|
36141
|
+
}
|
|
36142
|
+
async resumeCoordinatedCopy(intent, rename, left) {
|
|
36143
|
+
const { from, to, replace, root } = rename;
|
|
36144
|
+
const copies = new Copies();
|
|
36145
|
+
if (left && replace && await this.real(to))
|
|
36146
|
+
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36147
|
+
if (left) {
|
|
36148
|
+
const source = await this.locate(from, false);
|
|
36149
|
+
const target = await this.locate(parentOf11(to), true);
|
|
36150
|
+
await this.copy(
|
|
36151
|
+
source.handle,
|
|
36152
|
+
target.handle,
|
|
36153
|
+
baseOf4(to),
|
|
36154
|
+
{ copies }
|
|
36155
|
+
);
|
|
36156
|
+
this.forget(from);
|
|
36157
|
+
this.forget(to);
|
|
36158
|
+
}
|
|
36159
|
+
const mark = left ? vacatedAt(from) : void 0;
|
|
36160
|
+
if ((await this.meta.under(from)).some((entry) => !entry.vacated)) {
|
|
36161
|
+
await this.meta.move(
|
|
36162
|
+
from,
|
|
36163
|
+
to,
|
|
36164
|
+
(moved3) => ({
|
|
36165
|
+
...occupied(moved3),
|
|
36166
|
+
...root,
|
|
36167
|
+
ino: occupied(moved3).ino ?? root?.ino ?? inodeOf(from),
|
|
36168
|
+
path: to
|
|
36169
|
+
}),
|
|
36170
|
+
mark
|
|
36171
|
+
);
|
|
36172
|
+
} else if (mark) await this.meta.update(from, () => mark);
|
|
36173
|
+
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock, copies.remaining);
|
|
36174
|
+
else await this.meta.update(intent, () => void 0);
|
|
36175
|
+
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36176
|
+
}
|
|
35969
36177
|
async finishRename(entry) {
|
|
35970
36178
|
const [current] = await this.meta.under(entry.path);
|
|
35971
36179
|
if (current?.rename === void 0) return;
|
|
35972
|
-
const { from, to,
|
|
36180
|
+
const { from, to, root, emptyBackup, cleanupOnly, sourceCleanup } = current.rename;
|
|
36181
|
+
if (sourceCleanup !== void 0) return this.cleanSource(entry.path, from, sourceCleanup);
|
|
35973
36182
|
if (emptyBackup) this.hiddenBackups.add(emptyBackup);
|
|
35974
36183
|
if (emptyBackup && cleanupOnly) return this.cleanSwapIntent(entry.path, emptyBackup);
|
|
35975
36184
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
@@ -35989,59 +36198,7 @@ var OpfsFs = class {
|
|
|
35989
36198
|
);
|
|
35990
36199
|
return;
|
|
35991
36200
|
}
|
|
35992
|
-
|
|
35993
|
-
if (current.rename.privateCopy) {
|
|
35994
|
-
if (left) {
|
|
35995
|
-
const src = await this.locate(from, false);
|
|
35996
|
-
const dir = await this.locate(parentOf11(to), true);
|
|
35997
|
-
const copies = /* @__PURE__ */ new Map();
|
|
35998
|
-
await this.duplicate(
|
|
35999
|
-
src.handle,
|
|
36000
|
-
dir.handle,
|
|
36001
|
-
baseOf4(to),
|
|
36002
|
-
copies,
|
|
36003
|
-
""
|
|
36004
|
-
);
|
|
36005
|
-
await this.commitPrivateCopy(
|
|
36006
|
-
from,
|
|
36007
|
-
to,
|
|
36008
|
-
root ?? { ino: inodeOf(from) },
|
|
36009
|
-
entry.path,
|
|
36010
|
-
copies
|
|
36011
|
-
);
|
|
36012
|
-
} else await this.meta.update(entry.path, () => void 0);
|
|
36013
|
-
return;
|
|
36014
|
-
}
|
|
36015
|
-
if (left && replace && await this.real(to))
|
|
36016
|
-
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36017
|
-
if (left) {
|
|
36018
|
-
const source = await this.locate(from, false);
|
|
36019
|
-
const target = await this.locate(parentOf11(to), true);
|
|
36020
|
-
await this.copy(
|
|
36021
|
-
source.handle,
|
|
36022
|
-
target.handle,
|
|
36023
|
-
baseOf4(to)
|
|
36024
|
-
);
|
|
36025
|
-
const [dir, name2] = await this.parent(from);
|
|
36026
|
-
await this.inDir(dir, (parent) => parent.removeEntry(name2, { recursive: true }));
|
|
36027
|
-
this.forget(from);
|
|
36028
|
-
this.forget(to);
|
|
36029
|
-
}
|
|
36030
|
-
if ((await this.meta.under(from)).some((entry2) => !entry2.vacated)) {
|
|
36031
|
-
await this.meta.move(
|
|
36032
|
-
from,
|
|
36033
|
-
to,
|
|
36034
|
-
(moved3) => ({
|
|
36035
|
-
...occupied(moved3),
|
|
36036
|
-
...root,
|
|
36037
|
-
ino: occupied(moved3).ino ?? root?.ino ?? inodeOf(from),
|
|
36038
|
-
path: to
|
|
36039
|
-
}),
|
|
36040
|
-
void 0
|
|
36041
|
-
);
|
|
36042
|
-
}
|
|
36043
|
-
await this.meta.update(entry.path, () => void 0);
|
|
36044
|
-
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36201
|
+
await this.resumeCopiedTree(entry.path, current.rename);
|
|
36045
36202
|
} finally {
|
|
36046
36203
|
this.renamingDirs.delete(barrier);
|
|
36047
36204
|
resolve2();
|
|
@@ -36216,6 +36373,7 @@ var OpfsFs = class {
|
|
|
36216
36373
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
36217
36374
|
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
36218
36375
|
}
|
|
36376
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2));
|
|
36219
36377
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
36220
36378
|
this.others++;
|
|
36221
36379
|
for await (const child2 of handle.values()) {
|
|
@@ -36233,6 +36391,7 @@ var OpfsFs = class {
|
|
|
36233
36391
|
await writable3.abort().catch(nothing2);
|
|
36234
36392
|
throw err;
|
|
36235
36393
|
}
|
|
36394
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2, file));
|
|
36236
36395
|
options.copies?.set(rest2, {
|
|
36237
36396
|
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
36238
36397
|
made: made2
|
|
@@ -36414,6 +36573,7 @@ function byIntent(a, b) {
|
|
|
36414
36573
|
return a.rename.at - b.rename.at;
|
|
36415
36574
|
}
|
|
36416
36575
|
var PLAIN3 = {
|
|
36576
|
+
lstat: OpfsFs.prototype.lstat,
|
|
36417
36577
|
rm: OpfsFs.prototype.rm,
|
|
36418
36578
|
realpath: OpfsFs.prototype.realpath
|
|
36419
36579
|
};
|
|
@@ -36454,7 +36614,7 @@ var WRITES = [
|
|
|
36454
36614
|
proto.createExclusive = function(...args) {
|
|
36455
36615
|
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
36456
36616
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
36457
|
-
return this.alonePlain(inner, args);
|
|
36617
|
+
return this.alonePlain("createExclusive", inner, args);
|
|
36458
36618
|
};
|
|
36459
36619
|
}
|
|
36460
36620
|
for (const [names2, op] of [
|
|
@@ -36470,7 +36630,7 @@ for (const [names2, op] of [
|
|
|
36470
36630
|
if (op === "read") await this.settledRename(args[0]);
|
|
36471
36631
|
if (this.amongPeers() || name2 === "writeSession")
|
|
36472
36632
|
return await this.peerOp(name2, args, inner);
|
|
36473
|
-
return await this.alonePlain(inner, args);
|
|
36633
|
+
return await this.alonePlain(name2, inner, args);
|
|
36474
36634
|
} catch (err) {
|
|
36475
36635
|
throw translate(err, String(args[0]), op, false);
|
|
36476
36636
|
}
|
|
@@ -36480,13 +36640,13 @@ for (const [names2, op] of [
|
|
|
36480
36640
|
|
|
36481
36641
|
// src/mount/medium.ts
|
|
36482
36642
|
var EMPTY_ROOT = { kind: "directory", size: 0, mtime: 0, mode: 16877 };
|
|
36483
|
-
var
|
|
36643
|
+
var absent2 = () => fsError2("ENOMEDIUM", "No medium found");
|
|
36484
36644
|
function mediumSlot(lost, onLost) {
|
|
36485
36645
|
let current;
|
|
36486
36646
|
function wrap(pick) {
|
|
36487
36647
|
return async (...args) => {
|
|
36488
36648
|
const medium = current;
|
|
36489
|
-
if (!medium) throw
|
|
36649
|
+
if (!medium) throw absent2();
|
|
36490
36650
|
try {
|
|
36491
36651
|
return await pick(medium.handlers)(...args);
|
|
36492
36652
|
} catch (err) {
|
|
@@ -36495,7 +36655,7 @@ function mediumSlot(lost, onLost) {
|
|
|
36495
36655
|
current = void 0;
|
|
36496
36656
|
onLost(medium.key);
|
|
36497
36657
|
}
|
|
36498
|
-
throw
|
|
36658
|
+
throw absent2();
|
|
36499
36659
|
}
|
|
36500
36660
|
};
|
|
36501
36661
|
}
|
|
@@ -45326,6 +45486,9 @@ var SqliteHandle = class _SqliteHandle {
|
|
|
45326
45486
|
this.id = id2;
|
|
45327
45487
|
this.name = name2;
|
|
45328
45488
|
}
|
|
45489
|
+
async getUniqueId() {
|
|
45490
|
+
return String(this.id);
|
|
45491
|
+
}
|
|
45329
45492
|
async isSameEntry(other) {
|
|
45330
45493
|
return other instanceof _SqliteHandle && other.files === this.files && other.id === this.id;
|
|
45331
45494
|
}
|
|
@@ -45572,7 +45735,19 @@ var Chunks = class {
|
|
|
45572
45735
|
this.size = size;
|
|
45573
45736
|
}
|
|
45574
45737
|
};
|
|
45738
|
+
var identities = /* @__PURE__ */ new WeakMap();
|
|
45739
|
+
function entryId(handle) {
|
|
45740
|
+
let id2 = identities.get(handle);
|
|
45741
|
+
if (!id2) {
|
|
45742
|
+
id2 = crypto.randomUUID();
|
|
45743
|
+
identities.set(handle, id2);
|
|
45744
|
+
}
|
|
45745
|
+
return id2;
|
|
45746
|
+
}
|
|
45575
45747
|
var MemoryFile = class {
|
|
45748
|
+
async getUniqueId() {
|
|
45749
|
+
return entryId(this);
|
|
45750
|
+
}
|
|
45576
45751
|
kind = "file";
|
|
45577
45752
|
name;
|
|
45578
45753
|
parent;
|
|
@@ -45658,6 +45833,9 @@ var MemoryFile = class {
|
|
|
45658
45833
|
}
|
|
45659
45834
|
};
|
|
45660
45835
|
var MemoryDirectory = class _MemoryDirectory {
|
|
45836
|
+
async getUniqueId() {
|
|
45837
|
+
return entryId(this);
|
|
45838
|
+
}
|
|
45661
45839
|
kind = "directory";
|
|
45662
45840
|
name;
|
|
45663
45841
|
parent;
|