diff options
author | allexzander <blackslayer4@gmail.com> | 2021-06-17 13:09:01 +0300 |
---|---|---|
committer | allexzander <blackslayer4@gmail.com> | 2021-07-01 11:59:21 +0300 |
commit | 22eba41cb85b9dcbee2d075b7bce5cf11411eda7 (patch) | |
tree | 45456926cc9e10260ae4a87855669be02b019741 /src/libsync/discovery.cpp | |
parent | c5982143aa3c7a1c38d62fd54113793f572b2505 (diff) |
Do not process non-directories and non-virtual files. Wipe empty online-only folder based on its pinState.
Signed-off-by: allexzander <blackslayer4@gmail.com>
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r-- | src/libsync/discovery.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 5e3bcfb2e..d4dc0689f 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -902,6 +902,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( return; } + if (!localEntry.isVirtualFile && !localEntry.isDirectory) { + 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; @@ -914,13 +918,19 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // 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; - if (!isFilePlaceHolder && !folderAvailability) { + const auto folderPinState = localEntry.isDirectory ? _discoveryData->_syncOptions._vfs->pinState(path._local) : PinState::Unspecified; + + if (!isFilePlaceHolder && !folderAvailability && !folderPinState) { // 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; + const auto isFolderPinStateOnlineOnly = (folderPinState && *folderPinState == PinState::OnlineOnly); + + const auto isFolderAvailabilityOnlineOnly = (folderAvailability && *folderAvailability == VfsItemAvailability::OnlineOnly); + + // a folder is considered online-only if: no files are hydrated, or, if it's an empty folder + const auto isOnlineOnlyFolder = isFolderAvailabilityOnlineOnly || !folderAvailability && isFolderPinStateOnlineOnly; if (!isFilePlaceHolder && !isOnlineOnlyFolder) { if (localEntry.isDirectory && folderAvailability && !isOnlineOnlyFolder) { @@ -942,6 +952,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( 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; + emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a file. It's going to get removed!"), path._local); } item->_instruction = CSYNC_INSTRUCTION_REMOVE; item->_direction = SyncFileItem::Down; |