@sinoia/hubdoc-tools 1.8.2 → 1.8.3

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.
Files changed (2) hide show
  1. package/cli.js +42 -12
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -732813,6 +732813,34 @@ var HubdocFs = class {
732813
732813
  async uploadUpdate(node) {
732814
732814
  await this.uploadNode(node, "update");
732815
732815
  }
732816
+ /**
732817
+ * If `node` has unpushed writes, upload them now and clear the dirty flag.
732818
+ * Called from `flush` / `fsync` / `release` so that `close(fd)` (or an
732819
+ * explicit `fsync(fd)`) in userspace blocks until the server has the new
732820
+ * bytes — makes read-after-write via the API (from another process, or
732821
+ * from the same one after close()) immediately consistent.
732822
+ *
732823
+ * The FUSE contract:
732824
+ * - `flush` fires on every `close(2)` in userspace (once per close, even
732825
+ * for dup'd fds).
732826
+ * - `release` fires only after the last reference to the file is dropped
732827
+ * by the kernel — potentially long after `close(2)` returned.
732828
+ * So `flush` (not `release`) is where the upload has to happen for the
732829
+ * close→read-back sequence to be reliable.
732830
+ */
732831
+ async flushDirty(node) {
732832
+ if (!node.dirty) return;
732833
+ if (this.opts.readOnly) return;
732834
+ if (node.localOnly) {
732835
+ node.dirty = false;
732836
+ node.mtime = /* @__PURE__ */ new Date();
732837
+ return;
732838
+ }
732839
+ if (node.isNew || !node.id) await this.uploadNew(node);
732840
+ else await this.uploadUpdate(node);
732841
+ node.dirty = false;
732842
+ node.mtime = /* @__PURE__ */ new Date();
732843
+ }
732816
732844
  invalidateParent(p3) {
732817
732845
  const parent = this.nodes.get(parentPath(p3));
732818
732846
  if (parent) parent.loadedAt = 0;
@@ -732956,19 +732984,21 @@ var HubdocFs = class {
732956
732984
  await import_fs_extra32.default.close(h3.localFd);
732957
732985
  } catch {
732958
732986
  }
732959
- if (h3.node.dirty && !ro && !h3.node.localOnly) {
732960
- if (h3.node.isNew || !h3.node.id) await this.uploadNew(h3.node);
732961
- else await this.uploadUpdate(h3.node);
732962
- h3.node.dirty = false;
732963
- h3.node.mtime = /* @__PURE__ */ new Date();
732964
- } else if (h3.node.dirty && h3.node.localOnly) {
732965
- h3.node.dirty = false;
732966
- h3.node.mtime = /* @__PURE__ */ new Date();
732967
- }
732987
+ await this.flushDirty(h3.node);
732988
+ cb(0);
732989
+ }),
732990
+ flush: wrap(async (_p, fd, cb) => {
732991
+ const h3 = this.handles.get(fd);
732992
+ if (!h3) return cb(0);
732993
+ await this.flushDirty(h3.node);
732994
+ cb(0);
732995
+ }),
732996
+ fsync: wrap(async (_p, fd, _datasync, cb) => {
732997
+ const h3 = this.handles.get(fd);
732998
+ if (!h3) return cb(0);
732999
+ await this.flushDirty(h3.node);
732968
733000
  cb(0);
732969
733001
  }),
732970
- flush: (_p, _fd, cb) => cb(0),
732971
- fsync: (_p, _fd, _datasync, cb) => cb(0),
732972
733002
  unlink: wrap(async (p3, cb) => {
732973
733003
  if (ro) return cb(Fuse.EACCES);
732974
733004
  const node = await this.resolve(p3);
@@ -733926,7 +733956,7 @@ async function handlePermissionsShow(id, opts) {
733926
733956
  // apps/cli/cli.ts
733927
733957
  var getVersion = () => {
733928
733958
  try {
733929
- if (true) return "1.8.2";
733959
+ if (true) return "1.8.3";
733930
733960
  } catch {
733931
733961
  }
733932
733962
  for (const candidate of [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinoia/hubdoc-tools",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Professional command-line tool for HubDoc document management and bulk import/export",
5
5
  "main": "cli.js",
6
6
  "bin": {