@rljson/fs-agent 0.0.63 → 0.0.65

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.
@@ -327,6 +327,15 @@ export declare class FsAgent {
327
327
  * tree that lacks it is not deleting it — it simply predates it.
328
328
  */
329
329
  private readonly _announcedFiles;
330
+ /**
331
+ * Files this node wrote because a peer sent them.
332
+ *
333
+ * Permission only: it is never consulted to decide whether the prune gate is
334
+ * armed, only to answer "may this particular file be pruned". A file the
335
+ * network handed us is one the network knows about, so the peer that sent it
336
+ * may later take it away.
337
+ */
338
+ private readonly _restoredFiles;
330
339
  /**
331
340
  * Files this restore DELETED.
332
341
  *
package/dist/fs-agent.js CHANGED
@@ -1207,6 +1207,15 @@ class FsAgent {
1207
1207
  * tree that lacks it is not deleting it — it simply predates it.
1208
1208
  */
1209
1209
  _announcedFiles = /* @__PURE__ */ new Set();
1210
+ /**
1211
+ * Files this node wrote because a peer sent them.
1212
+ *
1213
+ * Permission only: it is never consulted to decide whether the prune gate is
1214
+ * armed, only to answer "may this particular file be pruned". A file the
1215
+ * network handed us is one the network knows about, so the peer that sent it
1216
+ * may later take it away.
1217
+ */
1218
+ _restoredFiles = /* @__PURE__ */ new Set();
1210
1219
  /**
1211
1220
  * Files this restore DELETED.
1212
1221
  *
@@ -1662,6 +1671,7 @@ ${err.stack}` : String(err);
1662
1671
  try {
1663
1672
  await FsAgent._atomicWriteFile(filePath, fileBlob.content);
1664
1673
  this._restoreWritten++;
1674
+ this._restoredFiles.add(filePath);
1665
1675
  if (meta.mtime) {
1666
1676
  const mtime = new Date(meta.mtime);
1667
1677
  await utimes(filePath, mtime, mtime);
@@ -2016,7 +2026,7 @@ ${err.stack}` : String(err);
2016
2026
  }
2017
2027
  }
2018
2028
  } else if (!expectedFiles.has(fullPath) && preRestore.has(fullPath)) {
2019
- if (this._announcedFiles.size > 0 && !this._announcedFiles.has(fullPath)) {
2029
+ if (this._announcedFiles.size > 0 && !this._announcedFiles.has(fullPath) && !this._restoredFiles.has(fullPath)) {
2020
2030
  continue;
2021
2031
  }
2022
2032
  await rm(fullPath, { force: true });
@@ -2052,11 +2062,12 @@ ${err.stack}` : String(err);
2052
2062
  const initialIsNew = initialParentRef !== void 0 && initialTree.rootHash !== initialParentRef;
2053
2063
  const initialPrevious = initialIsNew ? await this._ancestryPrevious(db, treeKey, [initialParentRef]) : void 0;
2054
2064
  const isSilentJoiner = initialParentRef === void 0 && this._treeIsEmpty(initialTree);
2065
+ const resumingUnchanged = initialParentRef !== void 0 && initialTree.rootHash === initialParentRef;
2055
2066
  const initialRef = await FsAgent._withTimeout(
2056
2067
  new FsDbAdapter(db, treeKey).storeFsTree(initialTree, {
2057
2068
  ...options,
2058
2069
  previous: initialPrevious,
2059
- skipNotification: isSilentJoiner ? true : options?.skipNotification
2070
+ skipNotification: isSilentJoiner || resumingUnchanged ? true : options?.skipNotification
2060
2071
  }),
2061
2072
  this._timeouts.fetchTree,
2062
2073
  `syncToDb → initial storeFsTree(${treeKey})`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/fs-agent",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
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",