diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index ecfbeee5ffec..d523dd921c9e 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -485,7 +485,7 @@ void OwncloudPropagator::cleanupLocallyMovedFoldersFromNestedItems(SyncFileItemV QMap renamedDirectories; for (const auto &item : items) { // TODO: for now, let's only process uploads (for downloads, we need to also adjust PropagateLocalRename such that correct DB records and pin states are set) - if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_RENAME && item->_instruction == SyncFileItem::Up) { + if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_RENAME && item->_direction == SyncFileItem::Up) { renamedDirectories.insert(item->_file, item->_renameTarget); } } diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index ecfbc105f0d2..216cc7bf1278 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -314,58 +314,64 @@ void PropagateRemoteMove::finalize() return; } - if (!propagator()->_journal->getFilesBelowPath(_item->_renameTarget.toUtf8(), [&](const SyncJournalFileRecord &rec) { - // not sure if this is needed, inode seems to never change for move/rename - auto newItem = SyncFileItem::fromSyncJournalFileRecord(rec); - newItem->_originalFile = QString(newItem->_file).replace(_item->_renameTarget, origin); - newItem->_renameTarget = newItem->_file; - newItem->_instruction = CSYNC_INSTRUCTION_RENAME; - newItem->_direction = SyncFileItem::Up; - const auto fsPath = propagator()->fullLocalPath(newItem->_renameTarget); - quint64 inode = rec._inode; - if (!FileSystem::getInode(fsPath, &inode)) { - qCWarning(lcPropagateRemoteMove) << "Could not get inode for moved file" << fsPath; - return; - } - if (inode != rec._inode) { - auto newRec = rec; - newRec._inode = inode; - if (!propagator()->_journal->setFileRecord(newRec)) { - qCWarning(lcPropagateRemoteMove) << "Could not update inode for moved file" << newRec.path(); + int a = 5; + a = 6; + + if (vfs->mode() != Vfs::Off && vfs->mode() != Vfs::WindowsCfApi) { + if (!propagator()->_journal->getFilesBelowPath(_item->_renameTarget.toUtf8(), [&](const SyncJournalFileRecord &rec) { + // not sure if this is needed, inode seems to never change for move/rename + auto newItem = SyncFileItem::fromSyncJournalFileRecord(rec); + newItem->_originalFile = QString(newItem->_file).replace(_item->_renameTarget, origin); + newItem->_renameTarget = newItem->_file; + newItem->_instruction = CSYNC_INSTRUCTION_RENAME; + newItem->_direction = SyncFileItem::Up; + const auto fsPath = propagator()->fullLocalPath(newItem->_renameTarget); + quint64 inode = rec._inode; + if (!FileSystem::getInode(fsPath, &inode)) { + qCWarning(lcPropagateRemoteMove) << "Could not get inode for moved file" << fsPath; return; } - } - auto &vfs = propagator()->syncOptions()._vfs; - // TODO: vfs->pinState(origin); does not make sense as item is already gone from original location, do we need this? - auto pinState = vfs->pinState(newItem->_originalFile); - const auto targetFile = propagator()->fullLocalPath(newItem->_renameTarget); - - if (QFileInfo::exists(targetFile)) { - // Delete old db data. - if (!propagator()->_journal->deleteFileRecord(newItem->_originalFile)) { - qCWarning(lcPropagateRemoteMove) << "could not delete file from local DB" << newItem->_originalFile; + if (inode != rec._inode) { + auto newRec = rec; + newRec._inode = inode; + if (!propagator()->_journal->setFileRecord(newRec)) { + qCWarning(lcPropagateRemoteMove) << "Could not update inode for moved file" << newRec.path(); + return; + } } - // TODO: vfs->setPinState(origin, PinState::Inherited) will always fail as item is already gone from original location, do we - // need this? - if (!vfs->setPinState(newItem->_originalFile, PinState::Inherited)) { - qCWarning(lcPropagateRemoteMove) << "Could not set pin state of" << newItem->_originalFile << "to inherited"; + auto &vfs = propagator()->syncOptions()._vfs; + // TODO: vfs->pinState(origin); does not make sense as item is already gone from original location, do we need this? + auto pinState = vfs->pinState(newItem->_originalFile); + const auto targetFile = propagator()->fullLocalPath(newItem->_renameTarget); + + if (QFileInfo::exists(targetFile)) { + // Delete old db data. + if (!propagator()->_journal->deleteFileRecord(newItem->_originalFile)) { + qCWarning(lcPropagateRemoteMove) << "could not delete file from local DB" << newItem->_originalFile; + } + // TODO: vfs->setPinState(origin, PinState::Inherited) will always fail as item is already gone from original location, do we + // need this? + if (!vfs->setPinState(newItem->_originalFile, PinState::Inherited)) { + qCWarning(lcPropagateRemoteMove) << "Could not set pin state of" << newItem->_originalFile << "to inherited"; + } } - } - const auto result = propagator()->updateMetadata(*newItem); - if (!result) { - done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error()), ErrorCategory::GenericError); - return; - } else if (*result == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem->_file), ErrorCategory::GenericError); - return; - } - if (pinState && *pinState != PinState::Inherited && !vfs->setPinState(newItem->_renameTarget, *pinState)) { - done(SyncFileItem::NormalError, tr("Error setting pin state"), ErrorCategory::GenericError); - return; - } - })) { - qCWarning(lcPropagateRemoteMove) << "Could not update inode for moved files in" << _item->_renameTarget; + const auto result = propagator()->updateMetadata(*newItem); + if (!result) { + done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error()), ErrorCategory::GenericError); + return; + } else if (*result == Vfs::ConvertToPlaceholderResult::Locked) { + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem->_file), ErrorCategory::GenericError); + return; + } + if (pinState && *pinState != PinState::Inherited && !vfs->setPinState(newItem->_renameTarget, *pinState)) { + done(SyncFileItem::NormalError, tr("Error setting pin state"), ErrorCategory::GenericError); + return; + } + })) { + qCWarning(lcPropagateRemoteMove) << "Could not update inode for moved files in" << _item->_renameTarget; + } } + a = 7; } propagator()->_journal->commit("Remote Rename");