diff options
author | allexzander <blackslayer4@gmail.com> | 2021-06-08 17:20:07 +0300 |
---|---|---|
committer | allexzander <blackslayer4@gmail.com> | 2021-06-15 14:33:45 +0300 |
commit | a3d12a616b589571e5189a97d061c8039484c87b (patch) | |
tree | 33ff1acd32b107eac232b691166c34469f563a1b /src/libsync | |
parent | 6312f6dddeae5c773b4516f92d3c157404951c76 (diff) |
Add error message to GUI.
Signed-off-by: allexzander <blackslayer4@gmail.com>
Diffstat (limited to 'src/libsync')
-rw-r--r-- | src/libsync/discovery.cpp | 41 | ||||
-rw-r--r-- | src/libsync/discoveryphase.h | 2 | ||||
-rw-r--r-- | src/libsync/progressdispatcher.h | 9 | ||||
-rw-r--r-- | src/libsync/syncengine.cpp | 1 | ||||
-rw-r--r-- | src/libsync/syncengine.h | 2 |
5 files changed, 44 insertions, 11 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 2f52dbcde..cb9fb7ab3 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -894,22 +894,41 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( _childModified = true; auto postProcessLocalNew = [item, localEntry, path, this]() { - if (localEntry.isVirtualFile || localEntry.isDirectory) { - const bool isPlaceHolder = _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local); - - const bool isNonHydratedVfsFolder = (localEntry.isDirectory - && _discoveryData->_syncOptions._vfs->mode() != Vfs::Off - && *_discoveryData->_syncOptions._vfs->availability(path._local) == VfsItemAvailability::OnlineOnly); + // 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; + + 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; + } - // must be file placeholder or an online-only folder - if (isPlaceHolder || isNonHydratedVfsFolder) { - qCWarning(lcDisco) << "Wiping virtual file without db entry for" << path._local; + // 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 && !isNonHydratedVfsFolder) { - qCWarning(lcDisco) << "Virtual directory without db entry for" << path._local << "but it is half-hydrated, so, keeping it."; + 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; } qCWarning(lcDisco) << "Virtual file without db entry for" << path._local diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 7e31389c2..9868e3ec6 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -279,6 +279,8 @@ signals: * The path is relative to the sync folder, similar to item->_file */ void silentlyExcluded(const QString &folderPath); + + void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject); }; /// Implementation of DiscoveryPhase::adjustRenamedPath diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h index f2e7ae626..99415d544 100644 --- a/src/libsync/progressdispatcher.h +++ b/src/libsync/progressdispatcher.h @@ -291,6 +291,15 @@ signals: void syncError(const QString &folder, const QString &message, ErrorCategory category); /** + * @brief Emitted when an error needs to be added into GUI + * @param[out] folder The folder which is being processed + * @param[out] status of the error + * @param[out] full error message + * @param[out] subject (optional) + */ + void addErrorToGui(const QString &folder, SyncFileItem::Status status, const QString &errorMessage, const QString &subject); + + /** * @brief Emitted for a folder when a sync is done, listing all pending conflicts */ void folderConflicts(const QString &folder, const QStringList &conflictPaths); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 0751a7b66..7f480913d 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -592,6 +592,7 @@ void SyncEngine::startSync() _discoveryPhase.data(), PinState::AlwaysLocal, _journal->keyValueStoreGetInt("last_sync", 0), _discoveryPhase.data()); _discoveryPhase->startJob(discoveryJob); connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived); + connect(_discoveryPhase.data(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); } void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 5bc8dd802..a9e50a197 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -151,6 +151,8 @@ signals: /// We've produced a new sync error of a type. void syncError(const QString &message, ErrorCategory category = ErrorCategory::Normal); + void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject); + void finished(bool success); void started(); |