فهرست منبع

core: fix 'unpaired IN_MOVED_FROM but the file is still there' case

Daniele Bartolini 2 سال پیش
والد
کامیت
f6892e6a28
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      src/core/filesystem/file_monitor_linux.cpp

+ 6 - 4
src/core/filesystem/file_monitor_linux.cpp

@@ -10,6 +10,7 @@
 #include "core/filesystem/file_monitor.h"
 #include "core/filesystem/path.h"
 #include "core/memory/temp_allocator.inl"
+#include "core/os.h"
 #include "core/strings/dynamic_string.inl"
 #include "core/thread/thread.h"
 #include <dirent.h> // opendir, readdir
@@ -291,10 +292,11 @@ struct FileMonitorImpl
 				p += sizeof(inotify_event) + ev->len;
 			}
 
-			// Unpaired IN_MOVED_TO or IN_MOVE_FROM with missing IN_MOVED_TO (rename from outside
-			// watched directory).
-			if (cookie != 0) {
-				if (cookie_mask & IN_MOVED_TO || cookie_mask & IN_MOVED_FROM) {
+			// Unpaired IN_MOVED_FROM: file deleted (moved out to non-monitored dir).
+			if (cookie != 0 && cookie_mask & IN_MOVED_FROM) {
+				Stat st;
+				os::stat(st, cookie_path.c_str());
+				if (st.file_type == Stat::NO_ENTRY) {
 					_function(_user_data
 						, FileMonitorEvent::DELETED
 						, cookie_mask & IN_ISDIR