@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/node.js
CHANGED
|
@@ -7789,7 +7789,7 @@ function satisfies(version, range2) {
|
|
|
7789
7789
|
}
|
|
7790
7790
|
|
|
7791
7791
|
// src/version.ts
|
|
7792
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
7792
|
+
var KERNEL_VERSION = true ? "1.196.33" : "0.0.0-dev";
|
|
7793
7793
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7794
7794
|
function procVersion() {
|
|
7795
7795
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -11095,14 +11095,14 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
11095
11095
|
}
|
|
11096
11096
|
return target?.path;
|
|
11097
11097
|
}
|
|
11098
|
-
const
|
|
11098
|
+
const absent3 = (err) => {
|
|
11099
11099
|
if (missing3(err)) return EMPTY2;
|
|
11100
11100
|
throw err;
|
|
11101
11101
|
};
|
|
11102
11102
|
async function content(path, err) {
|
|
11103
11103
|
if (!missing3(err) || !(await linked2(path))?.isFile) throw err;
|
|
11104
11104
|
const target = await redirected2(path);
|
|
11105
|
-
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(
|
|
11105
|
+
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(absent3);
|
|
11106
11106
|
}
|
|
11107
11107
|
const ranged2 = rangedOps(fs);
|
|
11108
11108
|
async function stat(path, real) {
|
|
@@ -11179,7 +11179,7 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
11179
11179
|
pread: (path, offset, length2, version) => ranged2.pread(path, offset, length2, version).catch(async (err) => {
|
|
11180
11180
|
const target = missing3(err) ? await redirected2(path) : void 0;
|
|
11181
11181
|
if (target === void 0) throw err;
|
|
11182
|
-
return ranged2.pread(target, offset, length2).catch(
|
|
11182
|
+
return ranged2.pread(target, offset, length2).catch(absent3);
|
|
11183
11183
|
})
|
|
11184
11184
|
} : {}
|
|
11185
11185
|
};
|
|
@@ -11244,9 +11244,9 @@ function withEtcFiles(fs, files) {
|
|
|
11244
11244
|
const text = files.get(path)?.();
|
|
11245
11245
|
return text === void 0 ? void 0 : new TextEncoder().encode(text);
|
|
11246
11246
|
};
|
|
11247
|
-
const
|
|
11247
|
+
const absent3 = (path) => fs.lstat(path).then(() => false, missing4);
|
|
11248
11248
|
const follow2 = linkFollower(fs, files);
|
|
11249
|
-
const listedAbsent = async (path) => files.has(path) && await
|
|
11249
|
+
const listedAbsent = async (path) => files.has(path) && await absent3(path) ? bytesOf5(path) : void 0;
|
|
11250
11250
|
const fallback = (path, make) => async (err) => {
|
|
11251
11251
|
const at = missing4(err) ? await follow2(path) : void 0;
|
|
11252
11252
|
const bytes = at === void 0 ? void 0 : await listedAbsent(at);
|
|
@@ -11258,10 +11258,10 @@ function withEtcFiles(fs, files) {
|
|
|
11258
11258
|
const own = {
|
|
11259
11259
|
stat: (path) => fs.stat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
11260
11260
|
lstat: (path) => fs.lstat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
11261
|
-
exists: async (path) => await fs.exists(path) || files.has(path) && await
|
|
11261
|
+
exists: async (path) => await fs.exists(path) || files.has(path) && await absent3(path),
|
|
11262
11262
|
...fs.createExclusive ? {
|
|
11263
11263
|
createExclusive: async (path, owner) => {
|
|
11264
|
-
if (files.has(path) && await
|
|
11264
|
+
if (files.has(path) && await absent3(path)) throw fsError("EEXIST", path);
|
|
11265
11265
|
return fs.createExclusive.call(
|
|
11266
11266
|
fs,
|
|
11267
11267
|
path,
|
|
@@ -12464,11 +12464,11 @@ var FsWatchers = class {
|
|
|
12464
12464
|
}
|
|
12465
12465
|
},
|
|
12466
12466
|
rm: reshaping(async (path, options) => {
|
|
12467
|
-
const
|
|
12467
|
+
const absent3 = options?.force === true && await fs.lstat(path).then(
|
|
12468
12468
|
() => false,
|
|
12469
12469
|
() => true
|
|
12470
12470
|
);
|
|
12471
|
-
if (
|
|
12471
|
+
if (absent3) return fs.rm(path, options);
|
|
12472
12472
|
const retire = await retiring?.(path);
|
|
12473
12473
|
await removing(path, options);
|
|
12474
12474
|
await retire?.();
|
|
@@ -16044,8 +16044,8 @@ var DEV_PROBES = /* @__PURE__ */ new Set([
|
|
|
16044
16044
|
]);
|
|
16045
16045
|
async function devsOf(entry, req, result) {
|
|
16046
16046
|
if (req.devs !== true || !DEV_PROBES.has(req.op)) return result;
|
|
16047
|
-
const
|
|
16048
|
-
if (!
|
|
16047
|
+
const absent3 = result.ok ? result.kind === "json" && result.json === false : result.errno === "ENOENT";
|
|
16048
|
+
if (!absent3) return result;
|
|
16049
16049
|
const dev = await devTarget(entry, req, entry.fs.resolvePath(entry.cwd, req.path));
|
|
16050
16050
|
if (dev === void 0) return result;
|
|
16051
16051
|
return result.ok ? json2({ dev }) : { ...result, dev };
|
|
@@ -33952,6 +33952,44 @@ var PrivateRename = class {
|
|
|
33952
33952
|
}
|
|
33953
33953
|
};
|
|
33954
33954
|
|
|
33955
|
+
// src/fs/rename-cleanup.ts
|
|
33956
|
+
function cleanupId(handle) {
|
|
33957
|
+
return handle.getUniqueId?.();
|
|
33958
|
+
}
|
|
33959
|
+
async function copiedEntry(handle, path, file) {
|
|
33960
|
+
const id2 = await cleanupId(handle);
|
|
33961
|
+
return {
|
|
33962
|
+
path,
|
|
33963
|
+
kind: handle.kind,
|
|
33964
|
+
...id2 !== void 0 && { id: id2 },
|
|
33965
|
+
...file && { size: file.size, mtime: file.lastModified }
|
|
33966
|
+
};
|
|
33967
|
+
}
|
|
33968
|
+
function absent(err) {
|
|
33969
|
+
return err.name === "NotFoundError";
|
|
33970
|
+
}
|
|
33971
|
+
async function removeOne(parent, name2, rest2, entries) {
|
|
33972
|
+
const entry = entries.get(rest2);
|
|
33973
|
+
if (!entry) return;
|
|
33974
|
+
try {
|
|
33975
|
+
const handle = entry.kind === "file" ? await parent.getFileHandle(name2) : await parent.getDirectoryHandle(name2);
|
|
33976
|
+
if (entry.id !== void 0 && await cleanupId(handle) !== entry.id) return;
|
|
33977
|
+
if (handle.kind === "file") {
|
|
33978
|
+
const file = await handle.getFile();
|
|
33979
|
+
if (file.lastModified !== entry.mtime || file.size !== entry.size) return;
|
|
33980
|
+
} else {
|
|
33981
|
+
for await (const child2 of handle.keys())
|
|
33982
|
+
await removeOne(handle, child2, rest2 + "/" + child2, entries);
|
|
33983
|
+
}
|
|
33984
|
+
await parent.removeEntry(name2);
|
|
33985
|
+
} catch (err) {
|
|
33986
|
+
if (!absent(err) && err.name !== "TypeMismatchError") throw err;
|
|
33987
|
+
}
|
|
33988
|
+
}
|
|
33989
|
+
function removeCopied(parent, name2, manifest) {
|
|
33990
|
+
return removeOne(parent, name2, "", new Map(manifest.map((entry) => [entry.path, entry])));
|
|
33991
|
+
}
|
|
33992
|
+
|
|
33955
33993
|
// src/fs/opfs.ts
|
|
33956
33994
|
var S_IFDIR2 = 16384;
|
|
33957
33995
|
var S_IFREG3 = 32768;
|
|
@@ -33996,6 +34034,9 @@ var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
|
33996
34034
|
var PRIVATE_NATIVE = /* @__PURE__ */ Symbol("private-native");
|
|
33997
34035
|
var ACK_SAMPLES = 4096;
|
|
33998
34036
|
var INTENT_POLL_MS = 5;
|
|
34037
|
+
var Copies = class extends Map {
|
|
34038
|
+
remaining = [];
|
|
34039
|
+
};
|
|
33999
34040
|
function needsCopy(handle, swap) {
|
|
34000
34041
|
return swap || handle.kind === "directory" && !movable(handle);
|
|
34001
34042
|
}
|
|
@@ -34512,6 +34553,7 @@ var OpfsFs = class {
|
|
|
34512
34553
|
return view(this, { rejectLinks: true });
|
|
34513
34554
|
}
|
|
34514
34555
|
refuse(path, holding = false) {
|
|
34556
|
+
this.reserveWrite(path, holding);
|
|
34515
34557
|
if (isProtected(this.guarded, path) || holding && holdsProtected(this.guarded, path)) {
|
|
34516
34558
|
throw fsError("EROFS", path);
|
|
34517
34559
|
}
|
|
@@ -34723,6 +34765,7 @@ var OpfsFs = class {
|
|
|
34723
34765
|
return this.lookups - seen.op < lookups && performance.now() - seen.at < GLANCE_CAP_MS;
|
|
34724
34766
|
}
|
|
34725
34767
|
async handle(path) {
|
|
34768
|
+
if (this.sourceReservation(path)) throw fsError("ENOENT", path);
|
|
34726
34769
|
this.lookups++;
|
|
34727
34770
|
if (split2(path).length === 0) return this.root;
|
|
34728
34771
|
const cached = this.files.get(path);
|
|
@@ -35406,6 +35449,9 @@ var OpfsFs = class {
|
|
|
35406
35449
|
const name2 = baseOf4(link2.path);
|
|
35407
35450
|
if (!children3.has(name2)) children3.set(name2, link2);
|
|
35408
35451
|
}
|
|
35452
|
+
for (const source of this.pendingSources.values()) {
|
|
35453
|
+
if (parentOf11(source) === found.path) children3.delete(baseOf4(source));
|
|
35454
|
+
}
|
|
35409
35455
|
for (const backup of this.hiddenBackups) {
|
|
35410
35456
|
if (parentOf11(backup) === found.path) children3.delete(baseOf4(backup));
|
|
35411
35457
|
}
|
|
@@ -35585,7 +35631,7 @@ var OpfsFs = class {
|
|
|
35585
35631
|
);
|
|
35586
35632
|
}
|
|
35587
35633
|
async removalParentId(path) {
|
|
35588
|
-
const parent = await
|
|
35634
|
+
const parent = await PLAIN3.lstat.call(this, parentOf11(path));
|
|
35589
35635
|
return parent.isDirectory ? `${parent.dev ?? 0}:${parent.ino}` : void 0;
|
|
35590
35636
|
}
|
|
35591
35637
|
async removePhysical(path, recursive) {
|
|
@@ -35744,7 +35790,7 @@ var OpfsFs = class {
|
|
|
35744
35790
|
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
35745
35791
|
const place = async () => {
|
|
35746
35792
|
this.forget(destination);
|
|
35747
|
-
const copies =
|
|
35793
|
+
const copies = new Copies();
|
|
35748
35794
|
const root = { ino: inodeOf(source.path), ...moving };
|
|
35749
35795
|
const owned4 = lock ? { lock } : {};
|
|
35750
35796
|
hooks.notify?.();
|
|
@@ -35763,18 +35809,23 @@ var OpfsFs = class {
|
|
|
35763
35809
|
if (first) await this.rollBack(staged2, source.path, [first, second]);
|
|
35764
35810
|
throw err;
|
|
35765
35811
|
});
|
|
35766
|
-
if (swap) await
|
|
35812
|
+
if (swap) await PLAIN3.rm.call(this, destination);
|
|
35767
35813
|
if (second) await this.intend({ from: staged2, to: destination, root, ...owned4 }, second);
|
|
35768
35814
|
await this.meta.move(source.path, destination, carry, left);
|
|
35769
35815
|
this.movePending(source.path, destination);
|
|
35770
|
-
if (!moved2
|
|
35771
|
-
|
|
35816
|
+
if (!moved2 && first)
|
|
35817
|
+
await this.releaseSource(first, source.path, destination, left.ino, lock, copies.remaining);
|
|
35818
|
+
else if (first) await this.meta.update(first, () => void 0);
|
|
35772
35819
|
if (swap) {
|
|
35773
35820
|
const hidden = await dir.getDirectoryHandle(staging);
|
|
35821
|
+
copies.remaining = [];
|
|
35774
35822
|
const placed = await this.place(hidden, dir, name2, copies, copying);
|
|
35775
|
-
if (!placed
|
|
35823
|
+
if (!placed && second) {
|
|
35824
|
+
const mark = vacatedAt(staged2);
|
|
35825
|
+
await this.meta.update(staged2, () => mark);
|
|
35826
|
+
await this.releaseSource(second, staged2, destination, mark.ino, lock, copies.remaining);
|
|
35827
|
+
} else if (second) await this.meta.update(second, () => void 0);
|
|
35776
35828
|
}
|
|
35777
|
-
if (second) await this.meta.update(second, () => void 0);
|
|
35778
35829
|
await this.restamp(destination, copies);
|
|
35779
35830
|
this.changed(source.path, destination);
|
|
35780
35831
|
this.touch(Date.now(), parentOf11(source.path), parent.path);
|
|
@@ -35993,6 +36044,10 @@ var OpfsFs = class {
|
|
|
35993
36044
|
const left = (await this.meta.under(RENAMES2)).filter((entry) => entry.rename?.lock === move.lock).sort(byIntent);
|
|
35994
36045
|
for (const entry of left) await this.finishRename(entry);
|
|
35995
36046
|
});
|
|
36047
|
+
for (const entry of await this.meta.under(RENAMES2)) {
|
|
36048
|
+
if (entry.rename?.lock === move.lock && entry.rename.sourceCleanup !== void 0)
|
|
36049
|
+
this.syncSourceReservation(entry.path, entry.rename.from);
|
|
36050
|
+
}
|
|
35996
36051
|
this.peerMoves.delete(move.lock);
|
|
35997
36052
|
for (const [from, to] of move.trees) {
|
|
35998
36053
|
this.forget(from);
|
|
@@ -36020,9 +36075,10 @@ var OpfsFs = class {
|
|
|
36020
36075
|
}
|
|
36021
36076
|
aloneCalls = 0;
|
|
36022
36077
|
aloneDrain;
|
|
36023
|
-
async alonePlain(inner, args) {
|
|
36078
|
+
async alonePlain(name2, inner, args) {
|
|
36024
36079
|
this.aloneCalls++;
|
|
36025
36080
|
try {
|
|
36081
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
36026
36082
|
return await inner.apply(this, args);
|
|
36027
36083
|
} finally {
|
|
36028
36084
|
this.aloneCalls--;
|
|
@@ -36053,6 +36109,7 @@ var OpfsFs = class {
|
|
|
36053
36109
|
for (const at of paths) checked.push(...await this.peerSettled(at, listing, removing));
|
|
36054
36110
|
if (!checked.some((at) => this.peerAt(at, listing, removing))) break;
|
|
36055
36111
|
}
|
|
36112
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
36056
36113
|
const busy = { paths: checked, removing, release: () => void 0 };
|
|
36057
36114
|
const done4 = () => {
|
|
36058
36115
|
this.inflight.delete(busy);
|
|
@@ -36083,6 +36140,7 @@ var OpfsFs = class {
|
|
|
36083
36140
|
let sessionOwnsAdmission = false;
|
|
36084
36141
|
let native = false;
|
|
36085
36142
|
try {
|
|
36143
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
36086
36144
|
if (name2 === "writeSession") {
|
|
36087
36145
|
const session = await inner.apply(inside2, args);
|
|
36088
36146
|
sessionOwnsAdmission = true;
|
|
@@ -36141,7 +36199,7 @@ var OpfsFs = class {
|
|
|
36141
36199
|
const handle = source.handle;
|
|
36142
36200
|
const dir = parent.handle;
|
|
36143
36201
|
const name2 = baseOf4(to);
|
|
36144
|
-
const copies =
|
|
36202
|
+
const copies = new Copies();
|
|
36145
36203
|
const [entry] = await this.meta.get([source.path]);
|
|
36146
36204
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
36147
36205
|
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
@@ -36194,16 +36252,19 @@ var OpfsFs = class {
|
|
|
36194
36252
|
async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
|
|
36195
36253
|
const { ino, ...owner } = root;
|
|
36196
36254
|
const entries = await this.meta.get([from, to]);
|
|
36197
|
-
|
|
36255
|
+
let mark = entries[0];
|
|
36256
|
+
if (!mark?.vacated || entries[1]?.ino !== ino) {
|
|
36257
|
+
mark = vacatedAt(from);
|
|
36198
36258
|
await this.meta.move(
|
|
36199
36259
|
from,
|
|
36200
36260
|
to,
|
|
36201
36261
|
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
36202
|
-
|
|
36262
|
+
mark
|
|
36203
36263
|
);
|
|
36204
36264
|
}
|
|
36265
|
+
if (!emptyBackup)
|
|
36266
|
+
await this.releaseSource(intent, from, to, mark.ino, void 0, copies.remaining);
|
|
36205
36267
|
this.movePending(from, to);
|
|
36206
|
-
if (!emptyBackup) await this.removePhysical(from, true);
|
|
36207
36268
|
await this.restamp(to, copies);
|
|
36208
36269
|
this.changed(from, to);
|
|
36209
36270
|
this.touch(Date.now(), parentOf11(from), parentOf11(to));
|
|
@@ -36211,16 +36272,102 @@ var OpfsFs = class {
|
|
|
36211
36272
|
await this.intend({ from, to, root, emptyBackup, cleanupOnly: true }, intent);
|
|
36212
36273
|
return this.cleanSwapIntent(intent, emptyBackup);
|
|
36213
36274
|
}
|
|
36214
|
-
|
|
36275
|
+
}
|
|
36276
|
+
async sourceId(path) {
|
|
36277
|
+
const [dir, name2] = await this.parent(path);
|
|
36278
|
+
const parent = await this.dir(dir);
|
|
36279
|
+
let handle;
|
|
36280
|
+
try {
|
|
36281
|
+
handle = await this.child(parent, name2, "directory");
|
|
36282
|
+
} catch (err) {
|
|
36283
|
+
if (err.name !== "TypeMismatchError") throw err;
|
|
36284
|
+
handle = await this.child(parent, name2, "file");
|
|
36285
|
+
}
|
|
36286
|
+
return cleanupId(handle);
|
|
36287
|
+
}
|
|
36288
|
+
async releaseSource(intent, from, to, id2, lock, copiedEntries) {
|
|
36289
|
+
this.syncSourceReservation(intent, from);
|
|
36290
|
+
const physicalSource = copiedEntries?.find((entry) => entry.path === "")?.id;
|
|
36291
|
+
await this.intend(
|
|
36292
|
+
{
|
|
36293
|
+
from,
|
|
36294
|
+
to,
|
|
36295
|
+
sourceCleanup: id2,
|
|
36296
|
+
...lock && { lock },
|
|
36297
|
+
...physicalSource && { physicalSource },
|
|
36298
|
+
...copiedEntries && { copiedEntries }
|
|
36299
|
+
},
|
|
36300
|
+
intent
|
|
36301
|
+
);
|
|
36302
|
+
await this.cleanSource(intent, from, id2);
|
|
36303
|
+
}
|
|
36304
|
+
async cleanSource(intent, from, id2) {
|
|
36305
|
+
const remove = async () => {
|
|
36306
|
+
const [current] = await this.meta.under(intent);
|
|
36307
|
+
if (current?.rename?.sourceCleanup === id2) {
|
|
36308
|
+
const [reservation] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [from]);
|
|
36309
|
+
if (reservation?.vacated && reservation.ino === id2) {
|
|
36310
|
+
try {
|
|
36311
|
+
const expected = current.rename.physicalSource;
|
|
36312
|
+
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
36313
|
+
const [dir, name2] = await this.parent(from);
|
|
36314
|
+
await this.inDir(
|
|
36315
|
+
dir,
|
|
36316
|
+
(parent) => current.rename?.copiedEntries ? removeCopied(parent, name2, current.rename.copiedEntries) : parent.removeEntry(name2)
|
|
36317
|
+
);
|
|
36318
|
+
}
|
|
36319
|
+
} catch (err) {
|
|
36320
|
+
if (!missing6(err) && err.name !== "NotFoundError") return;
|
|
36321
|
+
}
|
|
36322
|
+
await this.meta.update(
|
|
36323
|
+
from,
|
|
36324
|
+
(current2) => current2?.vacated && current2.ino === reservation.ino ? vacatedAt(from) : current2
|
|
36325
|
+
);
|
|
36326
|
+
}
|
|
36327
|
+
await this.meta.update(intent, () => void 0);
|
|
36328
|
+
}
|
|
36329
|
+
this.syncSourceReservation(intent);
|
|
36330
|
+
};
|
|
36331
|
+
this.syncSourceReservation(intent, from);
|
|
36332
|
+
if (this.locks) await this.locks.request(this.lockPrefix + intent, remove);
|
|
36333
|
+
else await remove();
|
|
36215
36334
|
}
|
|
36216
36335
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
36217
36336
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
36337
|
+
copies.remaining.push(await copiedEntry(handle, rest2));
|
|
36218
36338
|
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
36219
36339
|
this.others++;
|
|
36220
36340
|
for await (const child2 of handle.values())
|
|
36221
36341
|
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
36222
36342
|
}
|
|
36223
36343
|
hiddenBackups = /* @__PURE__ */ new Set();
|
|
36344
|
+
pendingSources = /* @__PURE__ */ new Map();
|
|
36345
|
+
syncSourceReservation(intent, from) {
|
|
36346
|
+
const path = from ?? this.pendingSources.get(intent);
|
|
36347
|
+
if (from === void 0) this.pendingSources.delete(intent);
|
|
36348
|
+
else this.pendingSources.set(intent, from);
|
|
36349
|
+
if (path) this.forget(path);
|
|
36350
|
+
}
|
|
36351
|
+
async reservedOp(name2, args) {
|
|
36352
|
+
const touched = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
36353
|
+
for (const [intent, source] of this.pendingSources) {
|
|
36354
|
+
const [entry] = await this.meta.under(intent);
|
|
36355
|
+
if (entry?.rename?.sourceCleanup === void 0) this.syncSourceReservation(intent);
|
|
36356
|
+
else if (!READS.includes(name2) && touched.some((p) => {
|
|
36357
|
+
const at = normalizePath(p);
|
|
36358
|
+
return within11(at, source) || REMOVALS2.has(name2) && (at === "/" || within11(source, at));
|
|
36359
|
+
}))
|
|
36360
|
+
throw fsError("EBUSY", source);
|
|
36361
|
+
}
|
|
36362
|
+
}
|
|
36363
|
+
sourceReservation(path, ancestor = false) {
|
|
36364
|
+
for (const source of this.pendingSources.values())
|
|
36365
|
+
if (within11(path, source) || ancestor && within11(source, path)) return source;
|
|
36366
|
+
return void 0;
|
|
36367
|
+
}
|
|
36368
|
+
reserveWrite(path, ancestor = false) {
|
|
36369
|
+
if (this.sourceReservation(path, ancestor)) throw fsError("EBUSY", path);
|
|
36370
|
+
}
|
|
36224
36371
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
36225
36372
|
intents = 0;
|
|
36226
36373
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -36281,7 +36428,7 @@ var OpfsFs = class {
|
|
|
36281
36428
|
}
|
|
36282
36429
|
if (!left) {
|
|
36283
36430
|
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
36284
|
-
return this.commitPrivateCopy(from, to, root, intent,
|
|
36431
|
+
return this.commitPrivateCopy(from, to, root, intent, new Copies(), backup);
|
|
36285
36432
|
}
|
|
36286
36433
|
const staged2 = await this.swapEntry(backup);
|
|
36287
36434
|
if (staged2) {
|
|
@@ -36294,10 +36441,72 @@ var OpfsFs = class {
|
|
|
36294
36441
|
}
|
|
36295
36442
|
await this.dropSwapIntent(intent, backup);
|
|
36296
36443
|
}
|
|
36444
|
+
async resumeCopiedTree(intent, rename) {
|
|
36445
|
+
const { from, to, root } = rename;
|
|
36446
|
+
const left = await this.real(from);
|
|
36447
|
+
if (left && root) {
|
|
36448
|
+
const [mark, placed] = await this.meta.get([from, to]);
|
|
36449
|
+
if (mark?.vacated && mark.ino !== void 0 && placed?.ino === root.ino)
|
|
36450
|
+
return this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36451
|
+
}
|
|
36452
|
+
if (rename.privateCopy) {
|
|
36453
|
+
if (left) {
|
|
36454
|
+
const src = await this.locate(from, false);
|
|
36455
|
+
const dir = await this.locate(parentOf11(to), true);
|
|
36456
|
+
const copies = new Copies();
|
|
36457
|
+
await this.duplicate(
|
|
36458
|
+
src.handle,
|
|
36459
|
+
dir.handle,
|
|
36460
|
+
baseOf4(to),
|
|
36461
|
+
copies,
|
|
36462
|
+
""
|
|
36463
|
+
);
|
|
36464
|
+
await this.commitPrivateCopy(from, to, root ?? { ino: inodeOf(from) }, intent, copies);
|
|
36465
|
+
} else await this.meta.update(intent, () => void 0);
|
|
36466
|
+
return;
|
|
36467
|
+
}
|
|
36468
|
+
await this.resumeCoordinatedCopy(intent, rename, left);
|
|
36469
|
+
}
|
|
36470
|
+
async resumeCoordinatedCopy(intent, rename, left) {
|
|
36471
|
+
const { from, to, replace, root } = rename;
|
|
36472
|
+
const copies = new Copies();
|
|
36473
|
+
if (left && replace && await this.real(to))
|
|
36474
|
+
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36475
|
+
if (left) {
|
|
36476
|
+
const source = await this.locate(from, false);
|
|
36477
|
+
const target = await this.locate(parentOf11(to), true);
|
|
36478
|
+
await this.copy(
|
|
36479
|
+
source.handle,
|
|
36480
|
+
target.handle,
|
|
36481
|
+
baseOf4(to),
|
|
36482
|
+
{ copies }
|
|
36483
|
+
);
|
|
36484
|
+
this.forget(from);
|
|
36485
|
+
this.forget(to);
|
|
36486
|
+
}
|
|
36487
|
+
const mark = left ? vacatedAt(from) : void 0;
|
|
36488
|
+
if ((await this.meta.under(from)).some((entry) => !entry.vacated)) {
|
|
36489
|
+
await this.meta.move(
|
|
36490
|
+
from,
|
|
36491
|
+
to,
|
|
36492
|
+
(moved2) => ({
|
|
36493
|
+
...occupied(moved2),
|
|
36494
|
+
...root,
|
|
36495
|
+
ino: occupied(moved2).ino ?? root?.ino ?? inodeOf(from),
|
|
36496
|
+
path: to
|
|
36497
|
+
}),
|
|
36498
|
+
mark
|
|
36499
|
+
);
|
|
36500
|
+
} else if (mark) await this.meta.update(from, () => mark);
|
|
36501
|
+
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock, copies.remaining);
|
|
36502
|
+
else await this.meta.update(intent, () => void 0);
|
|
36503
|
+
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36504
|
+
}
|
|
36297
36505
|
async finishRename(entry) {
|
|
36298
36506
|
const [current] = await this.meta.under(entry.path);
|
|
36299
36507
|
if (current?.rename === void 0) return;
|
|
36300
|
-
const { from, to,
|
|
36508
|
+
const { from, to, root, emptyBackup, cleanupOnly, sourceCleanup } = current.rename;
|
|
36509
|
+
if (sourceCleanup !== void 0) return this.cleanSource(entry.path, from, sourceCleanup);
|
|
36301
36510
|
if (emptyBackup) this.hiddenBackups.add(emptyBackup);
|
|
36302
36511
|
if (emptyBackup && cleanupOnly) return this.cleanSwapIntent(entry.path, emptyBackup);
|
|
36303
36512
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
@@ -36317,59 +36526,7 @@ var OpfsFs = class {
|
|
|
36317
36526
|
);
|
|
36318
36527
|
return;
|
|
36319
36528
|
}
|
|
36320
|
-
|
|
36321
|
-
if (current.rename.privateCopy) {
|
|
36322
|
-
if (left) {
|
|
36323
|
-
const src = await this.locate(from, false);
|
|
36324
|
-
const dir = await this.locate(parentOf11(to), true);
|
|
36325
|
-
const copies = /* @__PURE__ */ new Map();
|
|
36326
|
-
await this.duplicate(
|
|
36327
|
-
src.handle,
|
|
36328
|
-
dir.handle,
|
|
36329
|
-
baseOf4(to),
|
|
36330
|
-
copies,
|
|
36331
|
-
""
|
|
36332
|
-
);
|
|
36333
|
-
await this.commitPrivateCopy(
|
|
36334
|
-
from,
|
|
36335
|
-
to,
|
|
36336
|
-
root ?? { ino: inodeOf(from) },
|
|
36337
|
-
entry.path,
|
|
36338
|
-
copies
|
|
36339
|
-
);
|
|
36340
|
-
} else await this.meta.update(entry.path, () => void 0);
|
|
36341
|
-
return;
|
|
36342
|
-
}
|
|
36343
|
-
if (left && replace && await this.real(to))
|
|
36344
|
-
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36345
|
-
if (left) {
|
|
36346
|
-
const source = await this.locate(from, false);
|
|
36347
|
-
const target = await this.locate(parentOf11(to), true);
|
|
36348
|
-
await this.copy(
|
|
36349
|
-
source.handle,
|
|
36350
|
-
target.handle,
|
|
36351
|
-
baseOf4(to)
|
|
36352
|
-
);
|
|
36353
|
-
const [dir, name2] = await this.parent(from);
|
|
36354
|
-
await this.inDir(dir, (parent) => parent.removeEntry(name2, { recursive: true }));
|
|
36355
|
-
this.forget(from);
|
|
36356
|
-
this.forget(to);
|
|
36357
|
-
}
|
|
36358
|
-
if ((await this.meta.under(from)).some((entry2) => !entry2.vacated)) {
|
|
36359
|
-
await this.meta.move(
|
|
36360
|
-
from,
|
|
36361
|
-
to,
|
|
36362
|
-
(moved2) => ({
|
|
36363
|
-
...occupied(moved2),
|
|
36364
|
-
...root,
|
|
36365
|
-
ino: occupied(moved2).ino ?? root?.ino ?? inodeOf(from),
|
|
36366
|
-
path: to
|
|
36367
|
-
}),
|
|
36368
|
-
void 0
|
|
36369
|
-
);
|
|
36370
|
-
}
|
|
36371
|
-
await this.meta.update(entry.path, () => void 0);
|
|
36372
|
-
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36529
|
+
await this.resumeCopiedTree(entry.path, current.rename);
|
|
36373
36530
|
} finally {
|
|
36374
36531
|
this.renamingDirs.delete(barrier);
|
|
36375
36532
|
resolve2();
|
|
@@ -36544,6 +36701,7 @@ var OpfsFs = class {
|
|
|
36544
36701
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
36545
36702
|
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
36546
36703
|
}
|
|
36704
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2));
|
|
36547
36705
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
36548
36706
|
this.others++;
|
|
36549
36707
|
for await (const child2 of handle.values()) {
|
|
@@ -36561,6 +36719,7 @@ var OpfsFs = class {
|
|
|
36561
36719
|
await writable3.abort().catch(nothing2);
|
|
36562
36720
|
throw err;
|
|
36563
36721
|
}
|
|
36722
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2, file));
|
|
36564
36723
|
options.copies?.set(rest2, {
|
|
36565
36724
|
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
36566
36725
|
made: made2
|
|
@@ -36742,6 +36901,7 @@ function byIntent(a, b) {
|
|
|
36742
36901
|
return a.rename.at - b.rename.at;
|
|
36743
36902
|
}
|
|
36744
36903
|
var PLAIN3 = {
|
|
36904
|
+
lstat: OpfsFs.prototype.lstat,
|
|
36745
36905
|
rm: OpfsFs.prototype.rm,
|
|
36746
36906
|
realpath: OpfsFs.prototype.realpath
|
|
36747
36907
|
};
|
|
@@ -36782,7 +36942,7 @@ var WRITES = [
|
|
|
36782
36942
|
proto.createExclusive = function(...args) {
|
|
36783
36943
|
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
36784
36944
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
36785
|
-
return this.alonePlain(inner, args);
|
|
36945
|
+
return this.alonePlain("createExclusive", inner, args);
|
|
36786
36946
|
};
|
|
36787
36947
|
}
|
|
36788
36948
|
for (const [names2, op] of [
|
|
@@ -36798,7 +36958,7 @@ for (const [names2, op] of [
|
|
|
36798
36958
|
if (op === "read") await this.settledRename(args[0]);
|
|
36799
36959
|
if (this.amongPeers() || name2 === "writeSession")
|
|
36800
36960
|
return await this.peerOp(name2, args, inner);
|
|
36801
|
-
return await this.alonePlain(inner, args);
|
|
36961
|
+
return await this.alonePlain(name2, inner, args);
|
|
36802
36962
|
} catch (err) {
|
|
36803
36963
|
throw translate(err, String(args[0]), op, false);
|
|
36804
36964
|
}
|
|
@@ -36808,13 +36968,13 @@ for (const [names2, op] of [
|
|
|
36808
36968
|
|
|
36809
36969
|
// src/mount/medium.ts
|
|
36810
36970
|
var EMPTY_ROOT = { kind: "directory", size: 0, mtime: 0, mode: 16877 };
|
|
36811
|
-
var
|
|
36971
|
+
var absent2 = () => fsError2("ENOMEDIUM", "No medium found");
|
|
36812
36972
|
function mediumSlot(lost, onLost) {
|
|
36813
36973
|
let current;
|
|
36814
36974
|
function wrap(pick) {
|
|
36815
36975
|
return async (...args) => {
|
|
36816
36976
|
const medium = current;
|
|
36817
|
-
if (!medium) throw
|
|
36977
|
+
if (!medium) throw absent2();
|
|
36818
36978
|
try {
|
|
36819
36979
|
return await pick(medium.handlers)(...args);
|
|
36820
36980
|
} catch (err) {
|
|
@@ -36823,7 +36983,7 @@ function mediumSlot(lost, onLost) {
|
|
|
36823
36983
|
current = void 0;
|
|
36824
36984
|
onLost(medium.key);
|
|
36825
36985
|
}
|
|
36826
|
-
throw
|
|
36986
|
+
throw absent2();
|
|
36827
36987
|
}
|
|
36828
36988
|
};
|
|
36829
36989
|
}
|
|
@@ -44022,7 +44182,19 @@ var Chunks = class {
|
|
|
44022
44182
|
this.size = size;
|
|
44023
44183
|
}
|
|
44024
44184
|
};
|
|
44185
|
+
var identities = /* @__PURE__ */ new WeakMap();
|
|
44186
|
+
function entryId(handle) {
|
|
44187
|
+
let id2 = identities.get(handle);
|
|
44188
|
+
if (!id2) {
|
|
44189
|
+
id2 = crypto.randomUUID();
|
|
44190
|
+
identities.set(handle, id2);
|
|
44191
|
+
}
|
|
44192
|
+
return id2;
|
|
44193
|
+
}
|
|
44025
44194
|
var MemoryFile = class {
|
|
44195
|
+
async getUniqueId() {
|
|
44196
|
+
return entryId(this);
|
|
44197
|
+
}
|
|
44026
44198
|
kind = "file";
|
|
44027
44199
|
name;
|
|
44028
44200
|
parent;
|
|
@@ -44108,6 +44280,9 @@ var MemoryFile = class {
|
|
|
44108
44280
|
}
|
|
44109
44281
|
};
|
|
44110
44282
|
var MemoryDirectory = class _MemoryDirectory {
|
|
44283
|
+
async getUniqueId() {
|
|
44284
|
+
return entryId(this);
|
|
44285
|
+
}
|
|
44111
44286
|
kind = "directory";
|
|
44112
44287
|
name;
|
|
44113
44288
|
parent;
|