diff options
author | allexzander <blackslayer4@gmail.com> | 2021-06-17 10:22:44 +0300 |
---|---|---|
committer | allexzander <blackslayer4@gmail.com> | 2021-07-01 11:59:21 +0300 |
commit | c5982143aa3c7a1c38d62fd54113793f572b2505 (patch) | |
tree | ec6711556d98e6e1b7a5c1e7d4ec113719446287 /src/libsync/discovery.cpp | |
parent | 48aefc1983388631ea2164a0111692eae379ce9a (diff) |
Refactoring.
Signed-off-by: allexzander <blackslayer4@gmail.com>
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r-- | src/libsync/discovery.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4ce8e1af6..5e3bcfb2e 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -896,7 +896,17 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( auto postProcessLocalNew = [item, localEntry, path, this]() { // 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 (!(_discoveryData && _discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() != Vfs::Off)) { + // for VFS files and folders only + return; + } + + Q_ASSERT(item->_instruction == CSYNC_INSTRUCTION_NEW); + if (item->_instruction != CSYNC_INSTRUCTION_NEW) { + qCWarning(lcDisco) << "Trying to wipe a virtual item" << path._local << " with item->_instruction" << item->_instruction; + return; + } // must be a dehydrated placeholder const bool isFilePlaceHolder = !localEntry.isDirectory && _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local); @@ -913,12 +923,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( 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) { + if (localEntry.isDirectory && folderAvailability && !isOnlineOnlyFolder) { + // a VFS folder but is not online0only (has some files hydrated) 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); - } + emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder. Those, conflicted, are going to get cleared!"), path._local); return; } qCWarning(lcDisco) << "Virtual file without db entry for" << path._local @@ -928,14 +936,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( 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) { + // if we're wiping a folder, we will only get this function called once and will wipe a folder along with it's files and also display one error in GUI qCInfo(lcDisco) << "Wiping virtual folder without db entry for" << path._local; + emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder. It's going to get cleared!"), path._local); } else { qCInfo(lcDisco) << "Wiping virtual file without db entry for" << path._local; } @@ -943,9 +947,6 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( 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); - } }; // Check if it is a move |