Skip to content

Commit cfff512

Browse files
committed
Address same-path delete-plus-create coalescing
Address same-path delete-plus-create coalescing
1 parent 451c0b8 commit cfff512

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/monitor.d

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,23 @@ struct ActionHolder {
264264
size_t[] pendingTargets;
265265
switch (type) {
266266
case ActionType.changed:
267-
if (src in srcMap && actions[srcMap[src]].type == ActionType.changed) {
268-
// skip duplicate operations
269-
return;
267+
if (src in srcMap) {
268+
size_t pendingTarget = srcMap[src];
269+
switch (actions[pendingTarget].type) {
270+
case ActionType.changed:
271+
// Skip duplicate change operations for the same path.
272+
return;
273+
case ActionType.deleted:
274+
// A delete followed by a change for the same path means the path is
275+
// present again before this event batch is processed. Suppress the
276+
// stale delete and process the final local state as a change.
277+
if (debugLogging) {addLogEntry("Coalescing same-path delete followed by change; suppressing stale delete: " ~ src, ["debug"]);}
278+
actions[pendingTarget].skipped = true;
279+
srcMap.remove(src);
280+
break;
281+
default:
282+
break;
283+
}
270284
}
271285
break;
272286
case ActionType.createDir:

0 commit comments

Comments
 (0)