Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix that item deleted after events of IN_MOVED_FROM & IN_CLOSE_WRITE #3045

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,9 @@ int main(string[] cliArgs) {
filesystemMonitor.onDelete = delegate(string path) {
if (verboseLogging) {addLogEntry("[M] Local item deleted: " ~ path, ["verbose"]);}
try {
addLogEntry("The operating system sent a deletion notification. Trying to delete the item as requested");
// The path has been deleted .. we cannot use isDir or isFile to advise what was deleted. This is the best we can Do
addLogEntry("The operating system sent a deletion notification. Trying to delete this item as requested: " ~ path);
// perform the delete action
syncEngineInstance.deleteByPath(path);
} catch (CurlException e) {
if (verboseLogging) {addLogEntry("Offline, cannot delete item: " ~ path, ["verbose"]);}
Expand Down
14 changes: 14 additions & 0 deletions src/monitor.d
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ final class Monitor {
} else if (event.mask & IN_CREATE) {
if (debugLogging) {addLogEntry("event IN_CREATE: " ~ path, ["debug"]);}
if (event.mask & IN_ISDIR) {
// fix from #2586
auto cookieToPath1 = cookieToPath.dup();
foreach (cookie, path1; cookieToPath1) {
if (path1 == path) {
cookieToPath.remove(cookie);
}
}
addRecursive(path);
if (useCallbacks) actionHolder.append(ActionType.createDir, path);
}
Expand All @@ -622,6 +629,13 @@ final class Monitor {
}
} else if ((event.mask & IN_CLOSE_WRITE) && !(event.mask & IN_ISDIR)) {
if (debugLogging) {addLogEntry("event IN_CLOSE_WRITE and not IN_ISDIR: " ~ path, ["debug"]);}
// fix from #2586
auto cookieToPath1 = cookieToPath.dup();
foreach (cookie, path1; cookieToPath1) {
if (path1 == path) {
cookieToPath.remove(cookie);
}
}
if (useCallbacks) actionHolder.append(ActionType.changed, path);
} else {
addLogEntry("inotify event unhandled: " ~ path);
Expand Down
Loading