mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
when moving a file, checks that it exists at origin or destination
current automated tests are never breaking the rule that a file that should be moved on client side (after a move was done server side) exists either at teh original path or the destination path. in practice it may happen (and I manually tested it) thet the sync engine decides to move a single file in two distinct places that decision will violate this rule and a debug build would then run into the assert Close #6462 Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
7a0b03aabc
commit
976dbd6df6
2 changed files with 25 additions and 3 deletions
|
@ -224,10 +224,10 @@ void PropagateLocalRename::start()
|
|||
|
||||
auto &vfs = propagator()->syncOptions()._vfs;
|
||||
const auto previousNameInDb = propagator()->adjustRenamedPath(_item->_file);
|
||||
const auto existingFile = propagator()->fullLocalPath(propagator()->adjustRenamedPath(_item->_file));
|
||||
const auto existingFile = propagator()->fullLocalPath(previousNameInDb);
|
||||
const auto targetFile = propagator()->fullLocalPath(_item->_renameTarget);
|
||||
|
||||
const auto fileAlreadyMoved = !QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile));
|
||||
const auto fileAlreadyMoved = !QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile)) && QFileInfo::exists(existingFile);
|
||||
auto pinState = OCC::PinState::Unspecified;
|
||||
if (!fileAlreadyMoved) {
|
||||
auto pinStateResult = vfs->pinState(propagator()->adjustRenamedPath(_item->_file));
|
||||
|
@ -239,6 +239,7 @@ void PropagateLocalRename::start()
|
|||
// if the file is a file underneath a moved dir, the _item->file is equal
|
||||
// to _item->renameTarget and the file is not moved as a result.
|
||||
qCDebug(lcPropagateLocalRename) << _item->_file << _item->_renameTarget << _item->_originalFile << previousNameInDb << (fileAlreadyMoved ? "original file has already moved" : "original file is still there");
|
||||
Q_ASSERT(QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile)) || QFileInfo::exists(existingFile));
|
||||
if (_item->_file != _item->_renameTarget) {
|
||||
propagator()->reportProgress(*_item, 0);
|
||||
qCDebug(lcPropagateLocalRename) << "MOVE " << existingFile << " => " << targetFile;
|
||||
|
|
|
@ -84,6 +84,12 @@ class TestSyncMove : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase()
|
||||
{
|
||||
Logger::instance()->setLogFlush(true);
|
||||
Logger::instance()->setLogDebug(true);
|
||||
}
|
||||
|
||||
void testMoveCustomRemoteRoot()
|
||||
{
|
||||
FileInfo subFolder(QStringLiteral("AS"), { { QStringLiteral("f1"), 4 } });
|
||||
|
@ -140,7 +146,22 @@ private slots:
|
|||
void testSelectiveSyncMovedFolder()
|
||||
{
|
||||
// issue #5224
|
||||
FakeFolder fakeFolder{ FileInfo{ QString(), { FileInfo{ QStringLiteral("parentFolder"), { FileInfo{ QStringLiteral("subFolderA"), { { QStringLiteral("fileA.txt"), 400 } } }, FileInfo{ QStringLiteral("subFolderB"), { { QStringLiteral("fileB.txt"), 400 } } } } } } } };
|
||||
FakeFolder fakeFolder{
|
||||
FileInfo{QString(), {
|
||||
FileInfo{QStringLiteral("parentFolder"), {
|
||||
FileInfo{QStringLiteral("subFolderA"), {
|
||||
{QStringLiteral("fileA.txt"), 400}
|
||||
}
|
||||
},
|
||||
FileInfo{QStringLiteral("subFolderB"), {
|
||||
{QStringLiteral("fileB.txt"), 400}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
auto expectedServerState = fakeFolder.currentRemoteState();
|
||||
|
|
Loading…
Reference in a new issue