@ai-ecoverse/slicc-kernel 1.55.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.
@@ -11905,7 +11905,7 @@ var HostfsClient = class {
11905
11905
  false,
11906
11906
  true
11907
11907
  );
11908
- await response.body?.cancel();
11908
+ return response.json().catch(() => null);
11909
11909
  }
11910
11910
  async read(fh, offset, size, ifMatch) {
11911
11911
  const response = await this.send(
@@ -11961,7 +11961,8 @@ var HostfsClient = class {
11961
11961
  }
11962
11962
  }
11963
11963
  };
11964
- function hostfsHandlers(current) {
11964
+ var RESTORE_AGAIN_MS = 3e4;
11965
+ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
11965
11966
  const handles = /* @__PURE__ */ new Map();
11966
11967
  let nextFh = 0;
11967
11968
  const fresh = (remote) => {
@@ -11974,10 +11975,18 @@ function hostfsHandlers(current) {
11974
11975
  return fresh(remote);
11975
11976
  };
11976
11977
  const call = (op, body = {}) => current().call(op, body);
11977
- const settle3 = (client, restore) => client.call("setattr", restore).catch((err) => {
11978
+ 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);
11979
+ const settle3 = (client, { was, ...restore }) => client.call("setattr", restore).catch((err) => {
11978
11980
  if (!client.gone || !client.cleanup) throw err;
11979
11981
  void client.cleanup("setattr", restore).catch(() => {
11980
11982
  });
11983
+ const timer = setTimeout(async () => {
11984
+ const seen = await client.cleanup?.("stat", { path: restore.path }).catch(() => null);
11985
+ if (same(was, restore.mode, seen))
11986
+ void client.cleanup?.("setattr", restore).catch(() => {
11987
+ });
11988
+ }, againMs);
11989
+ timer.unref?.();
11981
11990
  });
11982
11991
  async function writable(client, path, flags) {
11983
11992
  const { ifMatch: _, ...asked } = flags;
@@ -11986,9 +11995,10 @@ function hostfsHandlers(current) {
11986
11995
  return { opened: await opening(), restore: void 0 };
11987
11996
  } catch (err) {
11988
11997
  if (!flags.write || codeOf4(err) !== "EACCES") throw err;
11989
- const mode = (await client.call("stat", { path: rel(path) })).mode ?? 0;
11998
+ const was = await client.call("stat", { path: rel(path) });
11999
+ const mode = was.mode ?? 0;
11990
12000
  if (mode & 128) throw err;
11991
- const restore = { path: rel(path), mode };
12001
+ const restore = { path: rel(path), mode, was };
11992
12002
  const opened2 = await client.call("setattr", { path: rel(path), mode: mode | 128 }).then(opening).catch(async (again) => {
11993
12003
  await settle3(client, restore).catch(() => {
11994
12004
  });
@@ -12209,7 +12219,7 @@ function timed(transport, ms) {
12209
12219
  });
12210
12220
  const cleanup = async (op, body, skip) => {
12211
12221
  await Promise.allSettled([...inflight].filter((work) => work !== skip));
12212
- await transport.cleanup?.(op, body);
12222
+ return await transport.cleanup?.(op, body);
12213
12223
  };
12214
12224
  const release = (opened2) => {
12215
12225
  const fh = opened2?.fh;