Propagator: Fix renaming of files and case confflicts

Better fix for #1385 and #2318
This commit is contained in:
Olivier Goffart 2014-10-17 16:11:25 +02:00
parent 08156186fa
commit a5bd437d48
2 changed files with 13 additions and 2 deletions

View file

@ -48,6 +48,7 @@ mkdir($tmpdir);
createLocalFile( $tmpdir . "HELLO.dat", 100 );
createLocalFile( $tmpdir . "Hello.dat", 150 );
createLocalFile( $tmpdir . "Normal.dat", 110 );
createLocalFile( $tmpdir . "test.dat", 170 );
#put them in some directories
createRemoteDir( "dir" );
@ -73,14 +74,20 @@ assertLocalAndRemoteDir( '', 0);
printInfo( "Renaming one file to the same name as another one with different casing" );
moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
moveRemoteFile( 'dir/test.dat', 'dir/TEST.dat');
csync();
#It should not have do the move
# Hello -> NORMAL should not have do the move since the case conflict
assert( -e localDir() . 'dir/Hello.dat' );
assert( !-e localDir() . 'dir/NORMAL.dat' );
assert( -e localDir() . 'dir/Normal.dat' );
#test->TEST should have been worked.
assert( -e localDir() . 'dir/TEST.dat' );
assert( !-e localDir() . 'dir/test.dat' );
printInfo( "Another directory with the same name but different casing is created" );
createRemoteDir( "DIR" );

View file

@ -247,7 +247,11 @@ void PropagateLocalRename::start()
qDebug() << "MOVE " << _propagator->_localDir + _item._file << " => " << _propagator->_localDir + _item._renameTarget;
QFile file(_propagator->_localDir + _item._file);
if (_propagator->localFileNameClash(_item._renameTarget)) {
if (QString::compare(_item._file, _item._renameTarget, Qt::CaseInsensitive) != 0
&& _propagator->localFileNameClash(_item._renameTarget)) {
// Only use localFileNameClash for the destination if we know that the source was not
// the one conflicting (renaming A.txt -> a.txt is OK)
// Fixme: the file that is the reason for the clash could be named here,
// it would have to come out the localFileNameClash function
done(SyncFileItem::NormalError, tr( "File %1 can not be renamed to %2 because of a local file name clash")