Merge pull request #5261 from nextcloud/feature/do-not-show-error-status-on-editlocally-abort

Silence sync termination errors when running EditLocallyJob.
This commit is contained in:
allexzander 2022-12-12 18:42:13 +01:00 committed by GitHub
commit 73307a1161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -450,6 +450,7 @@ void EditLocallyJob::startEditLocally()
_syncTerminatedConnection = {};
startSyncBeforeOpening();
});
_folderForFile->setSilenceErrorsUntilNextSync(true);
_folderForFile->slotTerminateSync();
return;

View file

@ -308,6 +308,10 @@ void Folder::setSyncPaused(bool paused)
void Folder::setSyncState(SyncResult::Status state)
{
if (_silenceErrorsUntilNextSync && state == SyncResult::Error) {
_syncResult.setStatus(SyncResult::Status::Success);
return;
}
_syncResult.setStatus(state);
}
@ -832,6 +836,7 @@ bool Folder::reloadExcludes()
void Folder::startSync(const QStringList &pathList)
{
Q_UNUSED(pathList);
setSilenceErrorsUntilNextSync(false);
const auto singleItemDiscoveryOptions = _engine->singleItemDiscoveryOptions();
Q_ASSERT(!singleItemDiscoveryOptions.discoveryDirItem || singleItemDiscoveryOptions.discoveryDirItem->isDirectory());
if (singleItemDiscoveryOptions.discoveryDirItem && !singleItemDiscoveryOptions.discoveryDirItem->isDirectory()) {
@ -962,8 +967,10 @@ void Folder::setDirtyNetworkLimits()
void Folder::slotSyncError(const QString &message, ErrorCategory category)
{
_syncResult.appendErrorString(message);
emit ProgressDispatcher::instance()->syncError(alias(), message, category);
if (!_silenceErrorsUntilNextSync) {
_syncResult.appendErrorString(message);
emit ProgressDispatcher::instance()->syncError(alias(), message, category);
}
}
void Folder::slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject)
@ -998,6 +1005,9 @@ void Folder::slotSyncFinished(bool success)
if (syncError) {
_syncResult.setStatus(SyncResult::Error);
if (_silenceErrorsUntilNextSync) {
_syncResult.setStatus(SyncResult::Status::Success);
}
} else if (_syncResult.foundFilesNotSynced()) {
_syncResult.setStatus(SyncResult::Problem);
} else if (_definition.paused) {
@ -1151,6 +1161,11 @@ void Folder::slotNextSyncFullLocalDiscovery()
_timeSinceLastFullLocalDiscovery.invalidate();
}
void Folder::setSilenceErrorsUntilNextSync(bool silenceErrors)
{
_silenceErrorsUntilNextSync = silenceErrors;
}
void Folder::schedulePathForLocalDiscovery(const QString &relativePath)
{
_localDiscoveryTracker->addTouchedPath(relativePath.toUtf8());

View file

@ -368,6 +368,8 @@ public slots:
/** Ensures that the next sync performs a full local discovery. */
void slotNextSyncFullLocalDiscovery();
void setSilenceErrorsUntilNextSync(bool silenceErrors);
private slots:
void slotSyncStarted();
void slotSyncFinished(bool);
@ -506,6 +508,8 @@ private:
*/
bool _hasSwitchedToVfs = false;
bool _silenceErrorsUntilNextSync = false;
/**
* Watches this folder's local directory for changes.
*