@rljson/fs-agent 0.0.27 → 0.0.29
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 +22 -6
- package/package.json +2 -2
package/dist/fs-agent.js
CHANGED
|
@@ -2194,9 +2194,17 @@ ${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++) {
|
|
2201
|
+
if (!isNewestFromSender) {
|
|
2202
|
+
console.warn(
|
|
2203
|
+
`[FsAgent] ref=${treeRef.slice(0, 8)}… is not the newest its sender has advertised — ignoring it.`
|
|
2204
|
+
);
|
|
2205
|
+
connector.invalidateReceived(treeRef);
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2200
2208
|
this._scanner.pauseWatch();
|
|
2201
2209
|
this._remoteApplyInFlight = true;
|
|
2202
2210
|
try {
|
|
@@ -2250,7 +2258,7 @@ ${err.stack}` : String(err);
|
|
|
2250
2258
|
const applyOptions = restoreOptions?.cleanTarget && ancestryExpected && !declaresAncestry ? { ...restoreOptions, cleanTarget: false } : restoreOptions;
|
|
2251
2259
|
if (applyOptions !== restoreOptions) {
|
|
2252
2260
|
console.warn(
|
|
2253
|
-
`[FsAgent] ref=${treeRef.slice(0, 8)}… declares no ancestry — applying additively, not pruning
|
|
2261
|
+
`[FsAgent] ref=${treeRef.slice(0, 8)}… declares no ancestry — applying additively, not pruning.`
|
|
2254
2262
|
);
|
|
2255
2263
|
}
|
|
2256
2264
|
await FsAgent._withTimeout(
|
|
@@ -2322,30 +2330,38 @@ ${err.stack}` : String(err);
|
|
|
2322
2330
|
);
|
|
2323
2331
|
}
|
|
2324
2332
|
};
|
|
2325
|
-
const scheduleProcess = (ref, delayMs, recoveryAttempt, predecessorRefs) => {
|
|
2333
|
+
const scheduleProcess = (ref, delayMs, recoveryAttempt, predecessorRefs, isNewestFromSender = true) => {
|
|
2326
2334
|
if (pendingRef && pendingRef !== ref) {
|
|
2327
2335
|
connector.invalidateReceived(pendingRef);
|
|
2328
2336
|
}
|
|
2329
2337
|
pendingRef = ref;
|
|
2330
2338
|
pendingRecoveryAttempt = recoveryAttempt;
|
|
2331
2339
|
pendingPredecessorRefs = predecessorRefs;
|
|
2340
|
+
pendingIsNewest = isNewestFromSender;
|
|
2332
2341
|
if (fromDbTimer) clearTimeout(fromDbTimer);
|
|
2333
2342
|
fromDbTimer = setTimeout(async () => {
|
|
2334
2343
|
fromDbTimer = null;
|
|
2335
2344
|
const r = pendingRef;
|
|
2336
2345
|
const ra = pendingRecoveryAttempt;
|
|
2337
2346
|
const pr = pendingPredecessorRefs;
|
|
2347
|
+
const newest = pendingIsNewest;
|
|
2338
2348
|
pendingRef = null;
|
|
2339
2349
|
if (r) {
|
|
2340
|
-
await processRef(r, ra, pr);
|
|
2350
|
+
await processRef(r, ra, pr, newest);
|
|
2341
2351
|
}
|
|
2342
2352
|
}, delayMs);
|
|
2343
2353
|
};
|
|
2344
|
-
const syncCallback = (treeRef, predecessorRefs) => {
|
|
2354
|
+
const syncCallback = (treeRef, predecessorRefs, info) => {
|
|
2345
2355
|
if (!treeRef || typeof treeRef !== "string") {
|
|
2346
2356
|
return Promise.resolve();
|
|
2347
2357
|
}
|
|
2348
|
-
scheduleProcess(
|
|
2358
|
+
scheduleProcess(
|
|
2359
|
+
treeRef,
|
|
2360
|
+
this._timeouts.debounceMs,
|
|
2361
|
+
0,
|
|
2362
|
+
predecessorRefs,
|
|
2363
|
+
info?.isNewestFromSender ?? true
|
|
2364
|
+
);
|
|
2349
2365
|
return Promise.resolve();
|
|
2350
2366
|
};
|
|
2351
2367
|
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.29",
|
|
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",
|