Piotr Caban : server: Don' t report rename events when file is moved between directories.

Alexandre Julliard julliard at winehq.org
Wed Jan 19 11:46:14 CST 2011


Module: wine
Branch: master
Commit: be5a757c7acaa83cd651e5e043819d074832d369
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=be5a757c7acaa83cd651e5e043819d074832d369

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Jan 18 11:24:49 2011 +0100

server: Don't report rename events when file is moved between directories.

---

 server/change.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/server/change.c b/server/change.c
index e448c13..6461e95 100644
--- a/server/change.c
+++ b/server/change.c
@@ -123,6 +123,7 @@ static struct fd *inotify_fd;
 
 struct change_record {
     struct list entry;
+    unsigned int cookie;
     struct filesystem_event event;
 };
 
@@ -605,7 +606,7 @@ static int inotify_get_poll_events( struct fd *fd )
 }
 
 static void inotify_do_change_notify( struct dir *dir, unsigned int action,
-                                      const char *relpath )
+                                      unsigned int cookie, const char *relpath )
 {
     struct change_record *record;
 
@@ -618,6 +619,7 @@ static void inotify_do_change_notify( struct dir *dir, unsigned int action,
         if (!record)
             return;
 
+        record->cookie = cookie;
         record->event.action = action;
         memcpy( record->event.name, relpath, len );
         record->event.len = len;
@@ -809,7 +811,7 @@ static void inotify_notify_all( struct inotify_event *ie )
     {
         LIST_FOR_EACH_ENTRY( dir, &i->dirs, struct dir, in_entry )
             if ((filter & dir->filter) && (i==inode || dir->subtree))
-                inotify_do_change_notify( dir, action, path );
+                inotify_do_change_notify( dir, action, ie->cookie, path );
 
         if (!i->name || !prepend( &path, i->name ))
             break;
@@ -1177,6 +1179,22 @@ DECL_HANDLER(read_change)
         LIST_FOR_EACH_ENTRY( record, &events, struct change_record, entry )
         {
             data_size_t len = offsetof( struct filesystem_event, name[record->event.len] );
+
+            /* FIXME: rename events are sometimes reported as delete/create */
+            if (record->event.action == FILE_ACTION_RENAMED_OLD_NAME)
+            {
+                struct list *elem = list_next( &events, &record->entry );
+                if (elem)
+                    next = LIST_ENTRY(elem, struct change_record, entry);
+
+                if (elem && next->cookie == record->cookie)
+                    next->cookie = 0;
+                else
+                    record->event.action = FILE_ACTION_REMOVED;
+            }
+            else if (record->event.action == FILE_ACTION_RENAMED_NEW_NAME && record->cookie)
+                record->event.action = FILE_ACTION_ADDED;
+
             memcpy( event, &record->event, len );
             event += len;
             if (len % sizeof(int))




More information about the wine-cvs mailing list