SyncEngine: fix inode after move if the file has moved on the file system
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 20 Jan 2016 12:44:30 +0000 (13:44 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Wed, 20 Jan 2016 12:49:12 +0000 (13:49 +0100)
This is the fix for issue #4370

Step to reproduce the bug:
 1) have lots of files in directory "dir1"
 2) do mkdir dir2 && mv dir1/* dir2
 3) DURING the sync (which takes time because of the many moves) do mkdir dir3 && mv dir2/* dir3/
 4) observe that files are PUT in the next sync

The problem is that SyncJournalFileRecord::SyncJournalFileRecord will fail to
get the inode after the forst move because the files are already moved on the
filesystem.  Normaly it should use the inode from the discovery phase in that
case but that is not working because it comes from the remote node in case of
moves, so the code in SyncEngine::treewalkFile would not set the inode.

Test in https://github.com/owncloud/smashbox/pull/143

src/libsync/syncengine.cpp

index 301c0fb5a4812ab7521429066f1ff91e4ebe0f2f..59dca10ccc4e8f63c5a86834644303c07cce67d3 100644 (file)
@@ -451,7 +451,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
     }
     item->_size = file->size;
 
-    if (!remote) {
+    if (!item->_inode) {
         item->_inode = file->inode;
     }