@ai-ecoverse/slicc-kernel 1.125.11 → 1.125.12

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.
@@ -6392,7 +6392,7 @@ var KERNEL_VERSION, OS_RELEASE;
6392
6392
  var init_version = __esm({
6393
6393
  "src/version.ts"() {
6394
6394
  "use strict";
6395
- KERNEL_VERSION = true ? "1.125.11" : "0.0.0-dev";
6395
+ KERNEL_VERSION = true ? "1.125.12" : "0.0.0-dev";
6396
6396
  OS_RELEASE = "6.0.0-slicc";
6397
6397
  }
6398
6398
  });
package/dist/node.js CHANGED
@@ -4359,6 +4359,7 @@ var ABSENT_NAMES = 4096;
4359
4359
  var FILE_HANDLES = 4096;
4360
4360
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
4361
4361
  var REPLACED_ATTEMPTS = 4;
4362
+ var RECONCILE_LISTINGS = 8;
4362
4363
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
4363
4364
  var ERRNO_BY_DOM_ERROR = {
4364
4365
  NotFoundError: "ENOENT",
@@ -5714,15 +5715,57 @@ var OpfsFs = class {
5714
5715
  timesBy: this.id
5715
5716
  }));
5716
5717
  }
5718
+ async present(paths) {
5719
+ const listed = /* @__PURE__ */ new Map();
5720
+ const done4 = /* @__PURE__ */ new Map();
5721
+ const list = (dir) => {
5722
+ const known = listed.get(dir);
5723
+ if (known !== void 0) return known;
5724
+ const listing = (async () => {
5725
+ const above = dir === "/" ? void 0 : await list(parentOf4(dir));
5726
+ if (above === null) return null;
5727
+ const handle = dir === "/" ? this.root : above?.get(baseOf(dir));
5728
+ if (handle?.kind !== "directory") return void 0;
5729
+ this.calls++;
5730
+ const children3 = /* @__PURE__ */ new Map();
5731
+ try {
5732
+ for await (const child of handle.values())
5733
+ children3.set(child.name, child);
5734
+ } catch {
5735
+ return null;
5736
+ }
5737
+ return children3;
5738
+ })().then((children3) => {
5739
+ done4.set(dir, children3);
5740
+ return children3;
5741
+ });
5742
+ listed.set(dir, listing);
5743
+ return listing;
5744
+ };
5745
+ const dirs = [...new Set(paths.filter((p) => split(p).length > 0).map(parentOf4))];
5746
+ let next3 = 0;
5747
+ const lister = async () => {
5748
+ while (next3 < dirs.length) await list(dirs[next3++]);
5749
+ };
5750
+ await Promise.all(Array.from({ length: Math.min(RECONCILE_LISTINGS, dirs.length) }, lister));
5751
+ return async (path) => {
5752
+ if (split(path).length === 0) return true;
5753
+ const listing = done4.get(parentOf4(path));
5754
+ if (listing === null) return this.real(path);
5755
+ return listing?.has(baseOf(path)) === true;
5756
+ };
5757
+ }
5717
5758
  async reconcile() {
5718
5759
  if (this.remote && await this.remote.peered()) return 0;
5719
5760
  let removed = 0;
5720
5761
  const entries = await this.meta.all();
5721
5762
  const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
5722
- for (const entry of entries) {
5723
- if (entry.vacated && carried.has(inodeOf(entry.path))) continue;
5724
- const real = await this.real(entry.path);
5725
- const stale = entry.link === void 0 ? !real : real || !await this.real(parentOf4(entry.path));
5763
+ const checked = entries.filter((e) => !(e.vacated && carried.has(inodeOf(e.path))));
5764
+ const real = await this.present(
5765
+ checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf4(e.path)])
5766
+ );
5767
+ for (const entry of checked) {
5768
+ const stale = entry.link === void 0 ? !await real(entry.path) : await real(entry.path) || !await real(parentOf4(entry.path));
5726
5769
  if (!stale) continue;
5727
5770
  const seen = JSON.stringify(entry);
5728
5771
  await this.meta.update(
@@ -7110,7 +7153,7 @@ function satisfies(version, range2) {
7110
7153
  }
7111
7154
 
7112
7155
  // src/version.ts
7113
- var KERNEL_VERSION = true ? "1.125.11" : "0.0.0-dev";
7156
+ var KERNEL_VERSION = true ? "1.125.12" : "0.0.0-dev";
7114
7157
  var OS_RELEASE = "6.0.0-slicc";
7115
7158
  function procVersion() {
7116
7159
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18386,9 +18429,21 @@ var VfsNode = class {
18386
18429
  }
18387
18430
  async keep() {
18388
18431
  const ranged2 = await this.prepare();
18389
- await ranged2?.pin();
18432
+ if (ranged2) await this.followed(() => ranged2.pin());
18390
18433
  }
18391
18434
  moving = /* @__PURE__ */ new Set();
18435
+ async followed(op) {
18436
+ for (; ; ) {
18437
+ const at = this.path;
18438
+ try {
18439
+ return await op();
18440
+ } catch (err) {
18441
+ if (!isMissing(err)) throw err;
18442
+ while (this.moving.size > 0) await Promise.all(this.moving);
18443
+ if (this.path === at) throw err;
18444
+ }
18445
+ }
18446
+ }
18392
18447
  async load() {
18393
18448
  if (this.revoked) throw new KernelError("EIO");
18394
18449
  while (!this.data) {
@@ -18434,7 +18489,7 @@ var VfsNode = class {
18434
18489
  }
18435
18490
  async pread(max, at) {
18436
18491
  const ranged2 = await this.prepare();
18437
- if (ranged2) return ranged2.read(at, max);
18492
+ if (ranged2) return this.followed(() => ranged2.read(at, max));
18438
18493
  const bytes = await this.load();
18439
18494
  const n = Math.max(0, Math.min(max, this.length - at));
18440
18495
  return bytes.slice(at, at + n);
@@ -18477,7 +18532,7 @@ var VfsNode = class {
18477
18532
  await this.fits(at + bytes.length);
18478
18533
  const ranged2 = await this.prepare();
18479
18534
  if (ranged2) {
18480
- await ranged2.write(at, bytes);
18535
+ await this.followed(() => ranged2.write(at, bytes));
18481
18536
  this.markDirty();
18482
18537
  return bytes.length;
18483
18538
  }
@@ -18546,8 +18601,9 @@ var VfsNode = class {
18546
18601
  this.dirty = false;
18547
18602
  const started = performance.now();
18548
18603
  try {
18549
- if (this.ranged) await this.ranged.flush();
18550
- else await this.fs.writeFile(this.path, this.data.slice(0, this.length));
18604
+ await this.followed(
18605
+ () => this.ranged ? this.ranged.flush() : this.fs.writeFile(this.path, this.data.slice(0, this.length))
18606
+ );
18551
18607
  } catch (err) {
18552
18608
  this.dirty = true;
18553
18609
  throw err;