[Pkg-owncloud-commits] [owncloud-client] 46/69: Download: Fix data loss when rename fails. #2428

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Nov 7 19:41:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 7440ffc0e6300bf6636e1fd73fbe3e136b5c67fa
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Wed Nov 5 11:00:46 2014 +0100

    Download: Fix data loss when rename fails. #2428
---
 src/mirall/propagator_qnam.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 5fbb0f3..199a650 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -802,6 +802,19 @@ void PropagateDownloadFileQNAM::downloadFinished()
 
     QString error;
     if (!FileSystem::renameReplace(_tmpFile.fileName(), fn, &error)) {
+        // If we moved away the original file due to a conflict but can't
+        // put the downloaded file in its place, we are in a bad spot:
+        // If we do nothing the next sync run will assume the user deleted
+        // the file!
+        // To avoid that, the file is removed from the metadata table entirely
+        // which makes it look like we're just about to initially download
+        // it.
+        if (isConflict) {
+            _propagator->_journal->deleteFileRecord(fn);
+            _propagator->_journal->commit("download finished");
+            _propagator->_anotherSyncNeeded = true;
+        }
+
         done(SyncFileItem::NormalError, error);
         return;
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list