@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.
@@ -1096,6 +1096,7 @@ var ABSENT_NAMES = 4096;
1096
1096
  var FILE_HANDLES = 4096;
1097
1097
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
1098
1098
  var REPLACED_ATTEMPTS = 4;
1099
+ var RECONCILE_LISTINGS = 8;
1099
1100
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
1100
1101
  var ERRNO_BY_DOM_ERROR = {
1101
1102
  NotFoundError: "ENOENT",
@@ -2455,15 +2456,57 @@ var OpfsFs = class {
2455
2456
  timesBy: this.id
2456
2457
  }));
2457
2458
  }
2459
+ async present(paths) {
2460
+ const listed = /* @__PURE__ */ new Map();
2461
+ const done4 = /* @__PURE__ */ new Map();
2462
+ const list = (dir) => {
2463
+ const known = listed.get(dir);
2464
+ if (known !== void 0) return known;
2465
+ const listing = (async () => {
2466
+ const above = dir === "/" ? void 0 : await list(parentOf3(dir));
2467
+ if (above === null) return null;
2468
+ const handle = dir === "/" ? this.root : above?.get(baseOf(dir));
2469
+ if (handle?.kind !== "directory") return void 0;
2470
+ this.calls++;
2471
+ const children3 = /* @__PURE__ */ new Map();
2472
+ try {
2473
+ for await (const child of handle.values())
2474
+ children3.set(child.name, child);
2475
+ } catch {
2476
+ return null;
2477
+ }
2478
+ return children3;
2479
+ })().then((children3) => {
2480
+ done4.set(dir, children3);
2481
+ return children3;
2482
+ });
2483
+ listed.set(dir, listing);
2484
+ return listing;
2485
+ };
2486
+ const dirs = [...new Set(paths.filter((p) => split(p).length > 0).map(parentOf3))];
2487
+ let next3 = 0;
2488
+ const lister = async () => {
2489
+ while (next3 < dirs.length) await list(dirs[next3++]);
2490
+ };
2491
+ await Promise.all(Array.from({ length: Math.min(RECONCILE_LISTINGS, dirs.length) }, lister));
2492
+ return async (path) => {
2493
+ if (split(path).length === 0) return true;
2494
+ const listing = done4.get(parentOf3(path));
2495
+ if (listing === null) return this.real(path);
2496
+ return listing?.has(baseOf(path)) === true;
2497
+ };
2498
+ }
2458
2499
  async reconcile() {
2459
2500
  if (this.remote && await this.remote.peered()) return 0;
2460
2501
  let removed = 0;
2461
2502
  const entries = await this.meta.all();
2462
2503
  const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
2463
- for (const entry of entries) {
2464
- if (entry.vacated && carried.has(inodeOf(entry.path))) continue;
2465
- const real = await this.real(entry.path);
2466
- const stale = entry.link === void 0 ? !real : real || !await this.real(parentOf3(entry.path));
2504
+ const checked = entries.filter((e) => !(e.vacated && carried.has(inodeOf(e.path))));
2505
+ const real = await this.present(
2506
+ checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf3(e.path)])
2507
+ );
2508
+ for (const entry of checked) {
2509
+ const stale = entry.link === void 0 ? !await real(entry.path) : await real(entry.path) || !await real(parentOf3(entry.path));
2467
2510
  if (!stale) continue;
2468
2511
  const seen = JSON.stringify(entry);
2469
2512
  await this.meta.update(
@@ -6656,7 +6699,7 @@ function satisfies(version, range2) {
6656
6699
  }
6657
6700
 
6658
6701
  // src/version.ts
6659
- var KERNEL_VERSION = true ? "1.125.11" : "0.0.0-dev";
6702
+ var KERNEL_VERSION = true ? "1.125.12" : "0.0.0-dev";
6660
6703
  var OS_RELEASE = "6.0.0-slicc";
6661
6704
  function procVersion() {
6662
6705
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18449,9 +18492,21 @@ var VfsNode = class {
18449
18492
  }
18450
18493
  async keep() {
18451
18494
  const ranged2 = await this.prepare();
18452
- await ranged2?.pin();
18495
+ if (ranged2) await this.followed(() => ranged2.pin());
18453
18496
  }
18454
18497
  moving = /* @__PURE__ */ new Set();
18498
+ async followed(op) {
18499
+ for (; ; ) {
18500
+ const at = this.path;
18501
+ try {
18502
+ return await op();
18503
+ } catch (err) {
18504
+ if (!isMissing(err)) throw err;
18505
+ while (this.moving.size > 0) await Promise.all(this.moving);
18506
+ if (this.path === at) throw err;
18507
+ }
18508
+ }
18509
+ }
18455
18510
  async load() {
18456
18511
  if (this.revoked) throw new KernelError("EIO");
18457
18512
  while (!this.data) {
@@ -18497,7 +18552,7 @@ var VfsNode = class {
18497
18552
  }
18498
18553
  async pread(max, at) {
18499
18554
  const ranged2 = await this.prepare();
18500
- if (ranged2) return ranged2.read(at, max);
18555
+ if (ranged2) return this.followed(() => ranged2.read(at, max));
18501
18556
  const bytes = await this.load();
18502
18557
  const n = Math.max(0, Math.min(max, this.length - at));
18503
18558
  return bytes.slice(at, at + n);
@@ -18540,7 +18595,7 @@ var VfsNode = class {
18540
18595
  await this.fits(at + bytes.length);
18541
18596
  const ranged2 = await this.prepare();
18542
18597
  if (ranged2) {
18543
- await ranged2.write(at, bytes);
18598
+ await this.followed(() => ranged2.write(at, bytes));
18544
18599
  this.markDirty();
18545
18600
  return bytes.length;
18546
18601
  }
@@ -18609,8 +18664,9 @@ var VfsNode = class {
18609
18664
  this.dirty = false;
18610
18665
  const started = performance.now();
18611
18666
  try {
18612
- if (this.ranged) await this.ranged.flush();
18613
- else await this.fs.writeFile(this.path, this.data.slice(0, this.length));
18667
+ await this.followed(
18668
+ () => this.ranged ? this.ranged.flush() : this.fs.writeFile(this.path, this.data.slice(0, this.length))
18669
+ );
18614
18670
  } catch (err) {
18615
18671
  this.dirty = true;
18616
18672
  throw err;