@rljson/fs-agent 0.0.27 → 0.0.28
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/fs-agent.js +18 -7
- package/package.json +2 -2
package/dist/fs-agent.js
CHANGED
|
@@ -2194,7 +2194,8 @@ ${err.stack}` : String(err);
|
|
|
2194
2194
|
let fromDbTimer = null;
|
|
2195
2195
|
let pendingRecoveryAttempt = 0;
|
|
2196
2196
|
let pendingPredecessorRefs;
|
|
2197
|
-
|
|
2197
|
+
let pendingIsNewest = true;
|
|
2198
|
+
const processRef = async (treeRef, recoveryAttempt = 0, predecessorRefs, isNewestFromSender = true) => {
|
|
2198
2199
|
const maxAttempts = this._timeouts.processRefRetries + 1;
|
|
2199
2200
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
2200
2201
|
this._scanner.pauseWatch();
|
|
@@ -2247,10 +2248,12 @@ ${err.stack}` : String(err);
|
|
|
2247
2248
|
}
|
|
2248
2249
|
const ancestryExpected = this._resolveConflicts;
|
|
2249
2250
|
const declaresAncestry = (predecessorRefs?.length ?? 0) > 0;
|
|
2250
|
-
const
|
|
2251
|
+
const staleAdvertisement = !isNewestFromSender;
|
|
2252
|
+
const withholdPrune = ancestryExpected && !declaresAncestry || staleAdvertisement;
|
|
2253
|
+
const applyOptions = restoreOptions?.cleanTarget && withholdPrune ? { ...restoreOptions, cleanTarget: false } : restoreOptions;
|
|
2251
2254
|
if (applyOptions !== restoreOptions) {
|
|
2252
2255
|
console.warn(
|
|
2253
|
-
`[FsAgent] ref=${treeRef.slice(0, 8)}…
|
|
2256
|
+
`[FsAgent] ref=${treeRef.slice(0, 8)}… ` + (staleAdvertisement ? "is not the newest its sender has advertised" : "declares no ancestry") + ` — applying additively, not pruning.`
|
|
2254
2257
|
);
|
|
2255
2258
|
}
|
|
2256
2259
|
await FsAgent._withTimeout(
|
|
@@ -2322,30 +2325,38 @@ ${err.stack}` : String(err);
|
|
|
2322
2325
|
);
|
|
2323
2326
|
}
|
|
2324
2327
|
};
|
|
2325
|
-
const scheduleProcess = (ref, delayMs, recoveryAttempt, predecessorRefs) => {
|
|
2328
|
+
const scheduleProcess = (ref, delayMs, recoveryAttempt, predecessorRefs, isNewestFromSender = true) => {
|
|
2326
2329
|
if (pendingRef && pendingRef !== ref) {
|
|
2327
2330
|
connector.invalidateReceived(pendingRef);
|
|
2328
2331
|
}
|
|
2329
2332
|
pendingRef = ref;
|
|
2330
2333
|
pendingRecoveryAttempt = recoveryAttempt;
|
|
2331
2334
|
pendingPredecessorRefs = predecessorRefs;
|
|
2335
|
+
pendingIsNewest = isNewestFromSender;
|
|
2332
2336
|
if (fromDbTimer) clearTimeout(fromDbTimer);
|
|
2333
2337
|
fromDbTimer = setTimeout(async () => {
|
|
2334
2338
|
fromDbTimer = null;
|
|
2335
2339
|
const r = pendingRef;
|
|
2336
2340
|
const ra = pendingRecoveryAttempt;
|
|
2337
2341
|
const pr = pendingPredecessorRefs;
|
|
2342
|
+
const newest = pendingIsNewest;
|
|
2338
2343
|
pendingRef = null;
|
|
2339
2344
|
if (r) {
|
|
2340
|
-
await processRef(r, ra, pr);
|
|
2345
|
+
await processRef(r, ra, pr, newest);
|
|
2341
2346
|
}
|
|
2342
2347
|
}, delayMs);
|
|
2343
2348
|
};
|
|
2344
|
-
const syncCallback = (treeRef, predecessorRefs) => {
|
|
2349
|
+
const syncCallback = (treeRef, predecessorRefs, info) => {
|
|
2345
2350
|
if (!treeRef || typeof treeRef !== "string") {
|
|
2346
2351
|
return Promise.resolve();
|
|
2347
2352
|
}
|
|
2348
|
-
scheduleProcess(
|
|
2353
|
+
scheduleProcess(
|
|
2354
|
+
treeRef,
|
|
2355
|
+
this._timeouts.debounceMs,
|
|
2356
|
+
0,
|
|
2357
|
+
predecessorRefs,
|
|
2358
|
+
info?.isNewestFromSender ?? true
|
|
2359
|
+
);
|
|
2349
2360
|
return Promise.resolve();
|
|
2350
2361
|
};
|
|
2351
2362
|
connector.listen(syncCallback);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/fs-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@rljson/bs": "^0.0.21",
|
|
54
|
-
"@rljson/db": "^0.0.
|
|
54
|
+
"@rljson/db": "^0.0.32",
|
|
55
55
|
"@rljson/hash": "^0.0.18",
|
|
56
56
|
"@rljson/io": "^0.0.66",
|
|
57
57
|
"@rljson/json": "^0.0.23",
|