Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>2022-02-04 18:22:02 +0300
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>2022-02-08 00:32:06 +0300
commit8decd475e55203301d6b8f55337cb544827c04b4 (patch)
tree0a2809f20dae6b96952896b335eaf823d0613af2 /src/libsync/discovery.cpp
parente89268bdd7b656939f2ddd070ab93bd52f751ae8 (diff)
clean transition when files with spaces exist already
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r--src/libsync/discovery.cpp73
1 files changed, 39 insertions, 34 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp
index ded16cc98..80d57201b 100644
--- a/src/libsync/discovery.cpp
+++ b/src/libsync/discovery.cpp
@@ -52,10 +52,10 @@ bool ProcessDirectoryJob::checkForInvalidFileName(const PathTuple &path,
if (entriesIter != entries.end()) {
QString errorMessage;
const auto newFileNameEntry = entriesIter->second;
- if (newFileNameEntry.serverEntry.isValid()) {
+ if (entry.serverEntry.isValid() && newFileNameEntry.serverEntry.isValid()) {
errorMessage = tr("File contains trailing spaces and could not be renamed, because a file with the same name already exists on the server.");
}
- if (newFileNameEntry.localEntry.isValid()) {
+ if (entry.localEntry.isValid() && newFileNameEntry.localEntry.isValid()) {
errorMessage = tr("File contains trailing spaces and could not be renamed, because a file with the same name already exists locally.");
}
@@ -71,7 +71,7 @@ bool ProcessDirectoryJob::checkForInvalidFileName(const PathTuple &path,
item->_instruction = CSYNC_INSTRUCTION_ERROR;
item->_status = SyncFileItem::NormalError;
item->_errorString = errorMessage;
- emit _discoveryData->itemDiscovered(item);
+ processFileFinalize(item, path, false, ParentNotChanged, ParentNotChanged);
return false;
}
}
@@ -852,6 +852,39 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
processFileFinalize(item, path, recurse, recurseQueryLocal, recurseQueryServer);
};
+ auto handleInvalidSpaceRename = [&] (SyncFileItem::Direction direction) {
+ if (_dirItem) {
+ path._target = _dirItem->_file + "/" + localEntry.renameName;
+ } else {
+ path._target = localEntry.renameName;
+ }
+ OCC::SyncJournalFileRecord base;
+ if (!_discoveryData->_statedb->getFileRecordByInode(localEntry.inode, &base)) {
+ dbError();
+ return;
+ }
+ const auto originalPath = base.path();
+ const auto adjustedOriginalPath = _discoveryData->adjustRenamedPath(originalPath, SyncFileItem::Down);
+ _discoveryData->_renamedItemsLocal.insert(originalPath, path._target);
+ item->_renameTarget = path._target;
+ path._server = adjustedOriginalPath;
+ if (_dirItem) {
+ item->_file = _dirItem->_file + "/" + localEntry.name;
+ } else {
+ item->_file = localEntry.name;
+ }
+ path._original = originalPath;
+ item->_originalFile = path._original;
+ item->_modtime = base._modtime;
+ item->_inode = base._inode;
+ item->_instruction = CSYNC_INSTRUCTION_RENAME;
+ item->_direction = direction;
+ item->_fileId = base._fileId;
+ item->_remotePerm = base._remotePerm;
+ item->_etag = base._etag;
+ item->_type = base._type;
+ };
+
if (!localEntry.isValid()) {
if (_queryLocal == ParentNotChanged && dbEntry.isValid()) {
// Not modified locally (ParentNotChanged)
@@ -933,6 +966,8 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
|| _discoveryData->_syncOptions._vfs->needsMetadataUpdate(*item))) {
item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
item->_direction = SyncFileItem::Down;
+ } else if (!localEntry.renameName.isEmpty()) {
+ handleInvalidSpaceRename(SyncFileItem::Up);
}
} else if (!typeChange && isVfsWithSuffix()
&& dbEntry.isVirtualFile() && !localEntry.isVirtualFile
@@ -1019,37 +1054,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
}
if (!localEntry.renameName.isEmpty()) {
- if (_dirItem) {
- path._target = _dirItem->_file + "/" + localEntry.renameName;
- } else {
- path._target = localEntry.renameName;
- }
- OCC::SyncJournalFileRecord base;
- if (!_discoveryData->_statedb->getFileRecordByInode(localEntry.inode, &base)) {
- dbError();
- return;
- }
- const auto originalPath = base.path();
- const auto adjustedOriginalPath = _discoveryData->adjustRenamedPath(originalPath, SyncFileItem::Down);
- _discoveryData->_renamedItemsLocal.insert(originalPath, path._target);
- item->_renameTarget = path._target;
- path._server = adjustedOriginalPath;
- if (_dirItem) {
- item->_file = _dirItem->_file + "/" + localEntry.name;
- } else {
- item->_file = localEntry.name;
- }
- path._original = originalPath;
- item->_originalFile = path._original;
- item->_modtime = base._modtime;
- item->_inode = base._inode;
- item->_instruction = CSYNC_INSTRUCTION_RENAME;
- item->_direction = SyncFileItem::Down;
- item->_fileId = base._fileId;
- item->_remotePerm = base._remotePerm;
- item->_etag = base._etag;
- item->_type = base._type;
-
+ handleInvalidSpaceRename(SyncFileItem::Down);
finalize();
return;
}