[Pkg-owncloud-commits] [owncloud-client] 32/69: Download: Avoid overwriting file with case conflict. #1914

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Nov 7 19:41:08 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 45eeb5065fc0c1019c825530a6217fdd8b2e8e99
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Wed Oct 29 11:23:44 2014 +0100

    Download: Avoid overwriting file with case conflict. #1914
---
 csync/tests/ownCloud/t8.pl     | 22 +++++++++++++++++++++-
 src/mirall/propagator_qnam.cpp | 12 ++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/csync/tests/ownCloud/t8.pl b/csync/tests/ownCloud/t8.pl
index b1138f5..4851f75 100755
--- a/csync/tests/ownCloud/t8.pl
+++ b/csync/tests/ownCloud/t8.pl
@@ -35,7 +35,7 @@ print "Hello, this is t8, a tester for syncing of files on a case sensitive FS\n
 # The test is run on a 'normal' file system, but we tell pwncloud that it is case preserving anyway
 $ENV{OWNCLOUD_TEST_CASE_PRESERVING} = "1";
 
-# FIXME!  the code does not work with parallelism
+# No parallelism for more deterministic action.
 $ENV{OWNCLOUD_MAX_PARALLEL}="1";
 
 initTesting();
@@ -112,6 +112,26 @@ assert( !-e localDir() . 'dir' );
 
 # dir/NORMAL.dat is still on the server
 
+
+printInfo( "Attempt downloading two clashing files in parallel" );
+
+# Enable parallelism
+$ENV{OWNCLOUD_MAX_PARALLEL}="2";
+
+my $tmpdir2 = "/tmp/t8/parallel/";
+mkdir($tmpdir2);
+createLocalFile( $tmpdir2 . "FILE.dat", 23251233 );
+createLocalFile( $tmpdir2 . "file.dat",       33 );
+createRemoteDir( "parallel" );
+glob_put( "$tmpdir2/*", "parallel" );
+
+csync();
+
+# We assume the smaller file finished first, blocking
+# the second file from being saved.
+assert( !-e localDir() . 'parallel/FILE.dat' );
+assert( -e localDir() . 'parallel/file.dat' );
+
 cleanup();
 system("rm -r " . $tmpdir);
 
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 8195454..5fbb0f3 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -771,10 +771,18 @@ void PropagateDownloadFileQNAM::downloadFinished()
 
     QString fn = _propagator->getFilePath(_item._file);
 
+    // In case of file name clash, report an error
+    // This can happen if another parallel download saved a clashing file.
+    if (_propagator->localFileNameClash(_item._file)) {
+        done( SyncFileItem::NormalError, tr("File %1 cannot be saved because of a local file name clash!")
+              .arg(QDir::toNativeSeparators(_item._file)) );
+        return;
+    }
 
+    // In case of conflict, make a backup of the old file
+    // Ignore conflicts where both files are binary equal
     bool isConflict = _item._instruction == CSYNC_INSTRUCTION_CONFLICT
-            && !FileSystem::fileEquals(fn, _tmpFile.fileName()); // compare the files to see if there was an actual conflict.
-    //In case of conflict, make a backup of the old file
+            && !FileSystem::fileEquals(fn, _tmpFile.fileName());
     if (isConflict) {
         QFile f(fn);
         QString conflictFileName = makeConflictFileName(fn, Utility::qDateTimeFromTime_t(_item._modtime));

-- 
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