mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
parent
f3be99e5b2
commit
ade4c11de3
7 changed files with 38 additions and 8 deletions
|
@ -132,13 +132,19 @@ void DiscoveryPhase::checkSelectiveSyncNewFolder(const QString &path, RemotePerm
|
|||
propfindJob->start();
|
||||
}
|
||||
|
||||
|
||||
/* Given a path on the remote, give the path as it is when the rename is done */
|
||||
QString DiscoveryPhase::adjustRenamedPath(const QString &original) const
|
||||
{
|
||||
return OCC::adjustRenamedPath(_renamedItems, original);
|
||||
}
|
||||
|
||||
QString adjustRenamedPath(const QMap<QString, QString> renamedItems, const QString original)
|
||||
{
|
||||
int slashPos = original.size();
|
||||
while ((slashPos = original.lastIndexOf('/', slashPos - 1)) > 0) {
|
||||
auto it = _renamedItems.constFind(original.left(slashPos));
|
||||
if (it != _renamedItems.constEnd()) {
|
||||
auto it = renamedItems.constFind(original.left(slashPos));
|
||||
if (it != renamedItems.constEnd()) {
|
||||
return *it + original.mid(slashPos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,4 +192,7 @@ signals:
|
|||
// A new folder was discovered and was not synced because of the confirmation feature
|
||||
void newBigFolder(const QString &folder, bool isExternal);
|
||||
};
|
||||
|
||||
/// Implementation of DiscoveryPhase::adjustRenamedPath
|
||||
QString adjustRenamedPath(const QMap<QString, QString> renamedItems, const QString original);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "common/utility.h"
|
||||
#include "account.h"
|
||||
#include "common/asserts.h"
|
||||
#include "discoveryphase.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windef.h>
|
||||
|
@ -718,6 +719,11 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item,
|
|||
return true;
|
||||
}
|
||||
|
||||
QString OwncloudPropagator::adjustRenamedPath(const QString &original) const
|
||||
{
|
||||
return OCC::adjustRenamedPath(_renamedDirectories, original);
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
|
||||
PropagatorJob::PropagatorJob(OwncloudPropagator *propagator)
|
||||
|
|
|
@ -503,6 +503,10 @@ public:
|
|||
bool createConflict(const SyncFileItemPtr &item,
|
||||
PropagatorCompositeJob *composite, QString *error);
|
||||
|
||||
|
||||
QMap<QString, QString> _renamedDirectories;
|
||||
QString adjustRenamedPath(const QString &original) const;
|
||||
|
||||
private slots:
|
||||
|
||||
void abortTimeout()
|
||||
|
|
|
@ -78,17 +78,18 @@ void PropagateRemoteMove::start()
|
|||
if (propagator()->_abortRequested.fetchAndAddRelaxed(0))
|
||||
return;
|
||||
|
||||
qCDebug(lcPropagateRemoteMove) << _item->_file << _item->_renameTarget;
|
||||
QString origin = propagator()->adjustRenamedPath(_item->_file);
|
||||
qCDebug(lcPropagateRemoteMove) << origin << _item->_renameTarget;
|
||||
|
||||
QString targetFile(propagator()->getFilePath(_item->_renameTarget));
|
||||
|
||||
if (_item->_file == _item->_renameTarget) {
|
||||
if (origin == _item->_renameTarget) {
|
||||
// The parent has been renamed already so there is nothing more to do.
|
||||
finalize();
|
||||
return;
|
||||
}
|
||||
|
||||
QString source = propagator()->_remoteFolder + _item->_file;
|
||||
QString source = propagator()->_remoteFolder + origin;
|
||||
QString destination = QDir::cleanPath(propagator()->account()->davUrl().path() + propagator()->_remoteFolder + _item->_renameTarget);
|
||||
auto &vfs = propagator()->syncOptions()._vfs;
|
||||
if (vfs->mode() == Vfs::WithSuffix
|
||||
|
@ -179,6 +180,7 @@ void PropagateRemoteMove::finalize()
|
|||
}
|
||||
|
||||
if (_item->isDirectory()) {
|
||||
propagator()->_renamedDirectories.insert(_item->_file, _item->_renameTarget);
|
||||
if (!adjustSelectiveSync(propagator()->_journal, _item->_file, _item->_renameTarget)) {
|
||||
done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
|
||||
return;
|
||||
|
|
|
@ -247,7 +247,7 @@ void PropagateLocalRename::start()
|
|||
if (propagator()->_abortRequested.fetchAndAddRelaxed(0))
|
||||
return;
|
||||
|
||||
QString existingFile = propagator()->getFilePath(_item->_file);
|
||||
QString existingFile = propagator()->getFilePath(propagator()->adjustRenamedPath(_item->_file));
|
||||
QString targetFile = propagator()->getFilePath(_item->_renameTarget);
|
||||
|
||||
// if the file is a file underneath a moved dir, the _item->file is equal
|
||||
|
@ -299,6 +299,7 @@ void PropagateLocalRename::start()
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
propagator()->_renamedDirectories.insert(oldFile, _item->_renameTarget);
|
||||
if (!PropagateRemoteMove::adjustSelectiveSync(propagator()->_journal, oldFile, _item->_renameTarget)) {
|
||||
done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
|
||||
return;
|
||||
|
|
|
@ -650,7 +650,6 @@ private slots:
|
|||
QCOMPARE(fakeFolder.currentLocalState(), expectedState);
|
||||
QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
|
||||
|
||||
/* FIXME - likely addressed by ogoffart's sync code refactor
|
||||
// Now, the revert, but "crossed"
|
||||
fakeFolder.localModifier().rename("Empty/A", "A");
|
||||
fakeFolder.localModifier().rename("AllEmpty/C", "C");
|
||||
|
@ -660,7 +659,16 @@ private slots:
|
|||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.currentLocalState(), expectedState);
|
||||
QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
|
||||
*/
|
||||
|
||||
// Reverse on remote
|
||||
fakeFolder.remoteModifier().rename("A/AllEmpty", "AllEmpty");
|
||||
fakeFolder.remoteModifier().rename("C/Empty", "Empty");
|
||||
fakeFolder.remoteModifier().rename("C", "AllEmpty/C");
|
||||
fakeFolder.remoteModifier().rename("A", "Empty/A");
|
||||
expectedState = fakeFolder.currentRemoteState();
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.currentLocalState(), expectedState);
|
||||
QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue