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:
authorallexzander <blackslayer4@gmail.com>2021-06-16 21:56:37 +0300
committerallexzander <blackslayer4@gmail.com>2021-07-01 11:59:20 +0300
commit48aefc1983388631ea2164a0111692eae379ce9a (patch)
tree0f4e654b227e061541a2bdc133af812bc71a065d /src/libsync/discovery.cpp
parent80267adb3a8076d91d5bea6d7544d8b759cc68b2 (diff)
Fix VFS crash and false conflict on local new.
Signed-off-by: allexzander <blackslayer4@gmail.com>
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r--src/libsync/discovery.cpp76
1 files changed, 43 insertions, 33 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp
index da6f48bff..4ce8e1af6 100644
--- a/src/libsync/discovery.cpp
+++ b/src/libsync/discovery.cpp
@@ -897,44 +897,54 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
// TODO: We may want to execute the same logic for non-VFS mode, as, moving/renaming the same folder by 2 or more clients at the same time is not possible in Web UI.
// Keeping it like this (for VFS files and folders only) just to fix a user issue.
const auto isVfsEnabled = _discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() != Vfs::Off;
- if (localEntry.isVirtualFile || (localEntry.isDirectory && isVfsEnabled)) {
- // must be a dehydrated placeholder
- const bool isFilePlaceHolder = !localEntry.isDirectory && _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local);
- // a folder must be online-only (no files should be hydrated)
- const bool isFolderPlaceholder = localEntry.isDirectory && *_discoveryData->_syncOptions._vfs->availability(path._local) == VfsItemAvailability::OnlineOnly;
+ // must be a dehydrated placeholder
+ const bool isFilePlaceHolder = !localEntry.isDirectory && _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local);
- Q_ASSERT(item->_instruction == CSYNC_INSTRUCTION_NEW);
- if (item->_instruction != CSYNC_INSTRUCTION_NEW) {
- qCWarning(lcDisco) << "Wiping virtual file without db entry for" << path._local << ". But, item->_instruction is" << item->_instruction;
- }
+ // either correct availability, or a result with error if the folder is new or otherwise has no availability set yet
+ const auto folderAvailability = localEntry.isDirectory ? _discoveryData->_syncOptions._vfs->availability(path._local) : Vfs::AvailabilityError::NoSuchItem;
- // must be a file placeholder or an online-only folder placeholder
- if (isFilePlaceHolder || isFolderPlaceholder) {
- if (isFolderPlaceholder) {
- qCInfo(lcDisco) << "Wiping virtual folder without db entry for" << path._local;
- } else {
- qCInfo(lcDisco) << "Wiping virtual file without db entry for" << path._local;
- }
- item->_instruction = CSYNC_INSTRUCTION_REMOVE;
- item->_direction = SyncFileItem::Down;
- // this flag needs to be unset, otherwise a folder would get marked as new in the processSubJobs
- _childModified = false;
- if (isFolderPlaceholder && _discoveryData) {
- emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder. It's going to get cleared!"), path._local);
- }
- } else {
- if (localEntry.isDirectory && !isFolderPlaceholder) {
- qCInfo(lcDisco) << "Virtual directory without db entry for" << path._local << "but it contains hydrated file(s), so let's keep it and reupload.";
- if (_discoveryData) {
- emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder. Those, conflicted, are going to get cleared!"), path._local);
- }
- return;
+ if (!isFilePlaceHolder && !folderAvailability) {
+ // not a file placeholder and not a synced folder placeholder (new local folder)
+ return;
+ }
+
+ // a folder must be online-only (no files should be hydrated)
+ const auto isOnlineOnlyFolder = folderAvailability && *folderAvailability == VfsItemAvailability::OnlineOnly;
+
+ if (!isFilePlaceHolder && !isOnlineOnlyFolder) {
+ // either a VFS file without db entry or a folder with one or more hydrated files
+ if (localEntry.isDirectory && folderAvailability && *folderAvailability != VfsItemAvailability::OnlineOnly) {
+ qCInfo(lcDisco) << "Virtual directory without db entry for" << path._local << "but it contains hydrated file(s), so let's keep it and reupload.";
+ if (_discoveryData) {
+ emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder. Those, conflicted, are going to get cleared!"), path._local);
}
- qCWarning(lcDisco) << "Virtual file without db entry for" << path._local
- << "but looks odd, keeping";
- item->_instruction = CSYNC_INSTRUCTION_IGNORE;
+ return;
}
+ qCWarning(lcDisco) << "Virtual file without db entry for" << path._local
+ << "but looks odd, keeping";
+ item->_instruction = CSYNC_INSTRUCTION_IGNORE;
+
+ return;
+ }
+
+ Q_ASSERT(item->_instruction == CSYNC_INSTRUCTION_NEW);
+ if (item->_instruction != CSYNC_INSTRUCTION_NEW) {
+ qCWarning(lcDisco) << "Wiping virtual file without db entry for" << path._local << ". But, item->_instruction is" << item->_instruction;
+ return;
+ }
+
+ if (isOnlineOnlyFolder) {
+ qCInfo(lcDisco) << "Wiping virtual folder without db entry for" << path._local;
+ } else {
+ qCInfo(lcDisco) << "Wiping virtual file without db entry for" << path._local;
+ }
+ item->_instruction = CSYNC_INSTRUCTION_REMOVE;
+ item->_direction = SyncFileItem::Down;
+ // this flag needs to be unset, otherwise a folder would get marked as new in the processSubJobs
+ _childModified = false;
+ if (isOnlineOnlyFolder && _discoveryData) {
+ emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder. It's going to get cleared!"), path._local);
}
};