@ai-ecoverse/slicc-kernel 1.146.4 → 1.146.5

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.
@@ -1376,6 +1376,28 @@ function prefixes(path) {
1376
1376
  function within2(path, root) {
1377
1377
  return path === root || path.startsWith(`${root}/`);
1378
1378
  }
1379
+ var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
1380
+ code: "ENOSPC"
1381
+ });
1382
+ var CHECKED_BYTES = 16 * 1024 * 1024;
1383
+ var Extent = class {
1384
+ floor = 0;
1385
+ exact;
1386
+ wrote(end) {
1387
+ this.floor = Math.max(this.floor, end);
1388
+ if (this.exact !== void 0) this.exact = Math.max(this.exact, end);
1389
+ }
1390
+ cut(size) {
1391
+ this.exact = size;
1392
+ this.floor = Math.min(this.floor, size);
1393
+ }
1394
+ big() {
1395
+ return Math.max(this.floor, this.exact ?? 0) >= CHECKED_BYTES;
1396
+ }
1397
+ check(size) {
1398
+ if (size < this.floor || this.exact !== void 0 && size < this.exact) throw unstored();
1399
+ }
1400
+ };
1379
1401
  var LOCKED = /* @__PURE__ */ new Set(["NotReadableError", "NoModificationAllowedError", "InvalidStateError"]);
1380
1402
  var SYNC_BACKOFF_MS = [5, 10, 20, 40, 80];
1381
1403
  async function openSync(handle) {
@@ -1401,14 +1423,22 @@ function writeAll(access2, at, bytes) {
1401
1423
  }
1402
1424
  }
1403
1425
  async function positioned(handle, op) {
1426
+ const extent = new Extent();
1404
1427
  const access2 = await openSync(handle);
1405
1428
  if (access2) {
1406
1429
  try {
1407
1430
  op({
1408
- write: (at, bytes) => writeAll(access2, at, bytes),
1409
- truncate: (n) => access2.truncate(n)
1431
+ write: (at, bytes) => {
1432
+ writeAll(access2, at, bytes);
1433
+ extent.wrote(at + bytes.length);
1434
+ },
1435
+ truncate: (n) => {
1436
+ access2.truncate(n);
1437
+ extent.cut(n);
1438
+ }
1410
1439
  });
1411
1440
  access2.flush();
1441
+ if (access2.getSize) extent.check(access2.getSize());
1412
1442
  } finally {
1413
1443
  access2.close();
1414
1444
  }
@@ -1417,14 +1447,25 @@ async function positioned(handle, op) {
1417
1447
  const writable2 = await handle.createWritable({ keepExistingData: true });
1418
1448
  try {
1419
1449
  await op({
1420
- write: (at, bytes) => writable2.write({ type: "write", position: at, data: bytes }),
1421
- truncate: (n) => writable2.truncate(n)
1450
+ write: async (at, bytes) => {
1451
+ await writable2.write({
1452
+ type: "write",
1453
+ position: at,
1454
+ data: bytes
1455
+ });
1456
+ extent.wrote(at + bytes.length);
1457
+ },
1458
+ truncate: async (n) => {
1459
+ await writable2.truncate(n);
1460
+ extent.cut(n);
1461
+ }
1422
1462
  });
1423
1463
  } catch (err) {
1424
1464
  await writable2.abort();
1425
1465
  throw err;
1426
1466
  }
1427
1467
  await writable2.close();
1468
+ if (extent.big()) extent.check((await handle.getFile()).size);
1428
1469
  }
1429
1470
  function syncAccessHandles(scope = globalThis) {
1430
1471
  const handle = scope.FileSystemFileHandle;
@@ -2403,6 +2444,11 @@ var OpfsFs = class {
2403
2444
  writable2 = await this.io(file.createWritable());
2404
2445
  await writable2.write(content);
2405
2446
  await writable2.close();
2447
+ if (typeof content !== "string" && content.length >= CHECKED_BYTES) {
2448
+ const extent = new Extent();
2449
+ extent.cut(content.length);
2450
+ extent.check((await file.getFile()).size);
2451
+ }
2406
2452
  } catch (err) {
2407
2453
  await writable2?.abort().catch(() => void 0);
2408
2454
  throw translate(err, path, "commit", false);
@@ -7728,7 +7774,7 @@ function satisfies(version, range2) {
7728
7774
  }
7729
7775
 
7730
7776
  // src/version.ts
7731
- var KERNEL_VERSION = true ? "1.146.4" : "0.0.0-dev";
7777
+ var KERNEL_VERSION = true ? "1.146.5" : "0.0.0-dev";
7732
7778
  var OS_RELEASE = "6.0.0-slicc";
7733
7779
  function procVersion() {
7734
7780
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC