@ai-ecoverse/slicc-kernel 1.56.0 → 1.56.1

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/dist/node.js CHANGED
@@ -11660,7 +11660,7 @@ var HostfsClient = class {
11660
11660
  false,
11661
11661
  true
11662
11662
  );
11663
- await response.body?.cancel();
11663
+ return response.json().catch(() => null);
11664
11664
  }
11665
11665
  async read(fh, offset, size, ifMatch) {
11666
11666
  const response = await this.send(
@@ -11716,7 +11716,8 @@ var HostfsClient = class {
11716
11716
  }
11717
11717
  }
11718
11718
  };
11719
- function hostfsHandlers(current) {
11719
+ var RESTORE_AGAIN_MS = 3e4;
11720
+ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
11720
11721
  const handles = /* @__PURE__ */ new Map();
11721
11722
  let nextFh = 0;
11722
11723
  const fresh = (remote) => {
@@ -11729,10 +11730,18 @@ function hostfsHandlers(current) {
11729
11730
  return fresh(remote);
11730
11731
  };
11731
11732
  const call = (op, body = {}) => current().call(op, body);
11732
- const settle = (client, restore) => client.call("setattr", restore).catch((err) => {
11733
+ const same = (was, mode, seen) => seen?.mode === (mode | 128) && (was.ino !== void 0 && seen.ino !== void 0 ? seen.ino === was.ino : seen.size === was.size && seen.mtime === was.mtime);
11734
+ const settle = (client, { was, ...restore }) => client.call("setattr", restore).catch((err) => {
11733
11735
  if (!client.gone || !client.cleanup) throw err;
11734
11736
  void client.cleanup("setattr", restore).catch(() => {
11735
11737
  });
11738
+ const timer = setTimeout(async () => {
11739
+ const seen = await client.cleanup?.("stat", { path: restore.path }).catch(() => null);
11740
+ if (same(was, restore.mode, seen))
11741
+ void client.cleanup?.("setattr", restore).catch(() => {
11742
+ });
11743
+ }, againMs);
11744
+ timer.unref?.();
11736
11745
  });
11737
11746
  async function writable(client, path, flags) {
11738
11747
  const { ifMatch: _, ...asked } = flags;
@@ -11741,9 +11750,10 @@ function hostfsHandlers(current) {
11741
11750
  return { opened: await opening(), restore: void 0 };
11742
11751
  } catch (err) {
11743
11752
  if (!flags.write || codeOf4(err) !== "EACCES") throw err;
11744
- const mode = (await client.call("stat", { path: rel(path) })).mode ?? 0;
11753
+ const was = await client.call("stat", { path: rel(path) });
11754
+ const mode = was.mode ?? 0;
11745
11755
  if (mode & 128) throw err;
11746
- const restore = { path: rel(path), mode };
11756
+ const restore = { path: rel(path), mode, was };
11747
11757
  const opened2 = await client.call("setattr", { path: rel(path), mode: mode | 128 }).then(opening).catch(async (again) => {
11748
11758
  await settle(client, restore).catch(() => {
11749
11759
  });
@@ -11964,7 +11974,7 @@ function timed(transport, ms) {
11964
11974
  });
11965
11975
  const cleanup = async (op, body, skip) => {
11966
11976
  await Promise.allSettled([...inflight].filter((work) => work !== skip));
11967
- await transport.cleanup?.(op, body);
11977
+ return await transport.cleanup?.(op, body);
11968
11978
  };
11969
11979
  const release = (opened2) => {
11970
11980
  const fh = opened2?.fh;