[Pkg-owncloud-commits] [owncloud-client] 173/332: Added t8.pl that test case sensitivity issues

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:56 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 cbc7942a004dcf10fc453bca39f59bd17997d1d5
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon Jul 7 13:00:38 2014 +0200

    Added t8.pl that test case sensitivity issues
    
    Made some change in the .cpp code in order to be able to test
    the code when the file system is case sensitive
---
 csync/tests/ownCloud/t8.pl        | 110 ++++++++++++++++++++++++++++++++++++++
 src/mirall/owncloudpropagator.cpp |  10 ++++
 src/mirall/propagatorjobs.cpp     |   3 +-
 src/mirall/utility.cpp            |   3 ++
 4 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/csync/tests/ownCloud/t8.pl b/csync/tests/ownCloud/t8.pl
new file mode 100755
index 0000000..e8825bc
--- /dev/null
+++ b/csync/tests/ownCloud/t8.pl
@@ -0,0 +1,110 @@
+#!/usr/bin/perl
+#
+# Test script for the ownCloud module of csync.
+# This script requires a running ownCloud instance accessible via HTTP.
+# It does quite some fancy tests and asserts the results.
+#
+# Copyright (C) by Olivier Goffart <ogoffart at woboq.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+use lib ".";
+
+use Carp::Assert;
+use File::Copy;
+use ownCloud::Test;
+
+use strict;
+
+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
+$ENV{OWNCLOUD_MAX_PARALLEL}="1";
+
+initTesting();
+
+printInfo( "Syncing two files with the same name that differ with case" );
+
+#create some files localy
+my $tmpdir = "/tmp/t8/";
+mkdir($tmpdir);
+createLocalFile( $tmpdir . "HELLO.dat", 100 );
+createLocalFile( $tmpdir . "Hello.dat", 150 );
+createLocalFile( $tmpdir . "Normal.dat", 110 );
+
+#put them in some directories
+createRemoteDir( "dir" );
+glob_put( "$tmpdir/*", "dir" );
+
+csync();
+
+# Check that only one of the two file was synced.
+# The one that exist here is undefined, the current implementation will take the
+# first one alphabetically,  but the other one would also be fine. What's imporant
+# is that there is only one.
+assert( -e localDir() . 'dir/HELLO.dat' );
+assert( !-e localDir() . 'dir/Hello.dat' );
+
+printInfo( "Remove one file should remove it on the server and download the other one" );
+unlink( localDir() . 'dir/HELLO.dat' );
+
+csync();
+assert( -e localDir() . 'dir/Hello.dat' );
+assert( !-e localDir() . 'dir/HELLO.dat' );
+assertLocalAndRemoteDir( '', 0);
+
+
+printInfo( "Renaming one file to the same name as another one with different casing" );
+moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
+
+csync();
+
+#It should not have do the move
+assert( -e localDir() . 'dir/Hello.dat' );
+assert( !-e localDir() . 'dir/NORMAL.dat' );
+assert( -e localDir() . 'dir/Normal.dat' );
+
+printInfo( "Another directory with the same name but different casing is created" );
+
+createRemoteDir( "DIR" );
+glob_put( "$tmpdir/*", "DIR" );
+
+csync();
+
+assert( !-e localDir() . 'DIR' );
+
+
+printInfo( "Remove the old dir localy" );
+
+system("rm -r " . localDir() . "dir");
+
+csync();
+
+# now DIR was fetched
+assert( -e localDir() . 'DIR' );
+assert( -e localDir() . 'DIR/HELLO.dat' );
+assert( !-e localDir() . 'DIR/Hello.dat' );
+assert( !-e localDir() . 'dir' );
+
+# dir/NORMAL.dat is still on the server
+
+cleanup();
+system("rm -r " . $tmpdir);
+
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 62376ba..876e97d 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -29,6 +29,7 @@
 
 #include <QStack>
 #include <QFileInfo>
+#include <QDir>
 
 namespace Mirall {
 
@@ -369,6 +370,15 @@ bool OwncloudPropagator::localFileNameClash( const QString& relFile )
                 re = true;
             }
         }
+#else
+        // On Linux, the file system is case sensitive, but this code is usefull for testing.
+        // Just check that there is no other file with the same name and different casing.
+        QFileInfo fileInfo(file);
+        const QString fn = fileInfo.fileName();
+        QStringList list = fileInfo.dir().entryList(QStringList() << fn);
+        if (list.count() > 1 || (list.count() == 1 && list[0] != fn)) {
+            re = true;
+        }
 #endif
     }
     return re;
diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp
index 081559f..a94c04a 100644
--- a/src/mirall/propagatorjobs.cpp
+++ b/src/mirall/propagatorjobs.cpp
@@ -108,8 +108,7 @@ void PropagateLocalMkdir::start()
 
     QDir newDir(_propagator->_localDir + _item._file);
     QString newDirStr = QDir::toNativeSeparators(newDir.path());
-    if( Utility::fsCasePreserving() && newDir.exists() &&
-            _propagator->localFileNameClash(_item._file ) ) {
+    if( Utility::fsCasePreserving() && _propagator->localFileNameClash(_item._file ) ) {
         qDebug() << "WARN: new directory to create locally already exists!";
         done( SyncFileItem::NormalError, tr("Attention, possible case sensitivity clash with %1").arg(newDirStr) );
         return;
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index 32e3229..f6c3c4b 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -342,6 +342,9 @@ bool Utility::fsCasePreserving()
     bool re = false;
     if( isWindows() || isMac() ) {
         re = true;
+    } else {
+        static bool isTest = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING").toInt();
+        re = isTest;
     }
     return re;
 }

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