@rljson/fs-agent 0.0.34 → 0.0.35

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.
@@ -622,6 +622,18 @@ export declare class FsAgent {
622
622
  * @param connector - Connector to broadcast on.
623
623
  */
624
624
  private _readvertiseAfterRefusal;
625
+ /**
626
+ * Whether a tree describes a folder holding nothing whatsoever.
627
+ *
628
+ * Deliberately conservative: an empty DIRECTORY counts as content. A user who
629
+ * creates a folder and puts a directory in it has made a statement about what
630
+ * should be there, and the silence this gates is only correct for an agent
631
+ * that has established nothing at all. Being wrong in that direction would
632
+ * mean a folder that never advertises until something else happens to change.
633
+ * @param tree - The tree to inspect.
634
+ * @returns `true` when the tree carries no entries at all.
635
+ */
636
+ private _treeIsEmpty;
625
637
  private _adoptAppliedRef;
626
638
  /**
627
639
  * Derives a deterministic content key from an FsTree.
package/dist/fs-agent.js CHANGED
@@ -1883,7 +1883,16 @@ ${err.stack}` : String(err);
1883
1883
  this._timeouts.fetchTree,
1884
1884
  `syncToDb → initial storeFsTree(${treeKey})`
1885
1885
  );
1886
- if (initialRef) {
1886
+ const isSilentJoiner = initialParentRef === void 0 && this._treeIsEmpty(initialTree);
1887
+ if (isSilentJoiner) {
1888
+ console.warn(
1889
+ `[FsAgent] ${this._rootPath} is empty and has no remembered state — joining quietly rather than announcing emptiness.`
1890
+ );
1891
+ this._currentRef = initialRef;
1892
+ this._persistCurrentRef(initialRef);
1893
+ this._lastSentContentKey = this._contentKeyFromTree(initialTree);
1894
+ }
1895
+ if (initialRef && !isSilentJoiner) {
1887
1896
  this._lastSentRef = initialRef;
1888
1897
  this._currentRef = initialRef;
1889
1898
  this._persistCurrentRef(initialRef);
@@ -2136,6 +2145,20 @@ ${err.stack}` : String(err);
2136
2145
  console.warn(`[FsAgent] re-announcement failed: ${String(err)}`);
2137
2146
  }
2138
2147
  }
2148
+ /**
2149
+ * Whether a tree describes a folder holding nothing whatsoever.
2150
+ *
2151
+ * Deliberately conservative: an empty DIRECTORY counts as content. A user who
2152
+ * creates a folder and puts a directory in it has made a statement about what
2153
+ * should be there, and the silence this gates is only correct for an agent
2154
+ * that has established nothing at all. Being wrong in that direction would
2155
+ * mean a folder that never advertises until something else happens to change.
2156
+ * @param tree - The tree to inspect.
2157
+ * @returns `true` when the tree carries no entries at all.
2158
+ */
2159
+ _treeIsEmpty(tree) {
2160
+ return this._getFileContentMap(tree).size === 0;
2161
+ }
2139
2162
  _adoptAppliedRef(connector, treeRef) {
2140
2163
  if (this._lastAppliedRef && this._lastAppliedRef !== treeRef) {
2141
2164
  connector.invalidateSent?.(this._lastAppliedRef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/fs-agent",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "Rljson fs-agent description",
5
5
  "homepage": "https://github.com/rljson/fs-agent",
6
6
  "bugs": "https://github.com/rljson/fs-agent/issues",