mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 05:15:40 +03:00
Propagator: Fix renaming of files and case confflicts
Better fix for #1385 and #2318
This commit is contained in:
parent
08156186fa
commit
a5bd437d48
2 changed files with 13 additions and 2 deletions
|
@ -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" );
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue