From: Matthieu Gallien Date: Tue, 11 Oct 2022 14:10:53 +0000 (+0200) Subject: add more metadata to sync errors to allow filtering X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~92^2^2~119^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0e002f35f4b4bf121aea03f40156b04c4ba440dc;p=nextcloud-desktop.git add more metadata to sync errors to allow filtering in order to be able to filter some errors when showing them into the main dialog activity list, add some more info about the error to know the origin (like a network issue or a sync issue) Signed-off-by: Matthieu Gallien --- diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 4ff5595a8..589a0a9c1 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -593,13 +593,29 @@ void ActivityListModel::accountStateHasChanged() void ActivityListModel::addErrorToActivityList(const Activity &activity, const ErrorType type) { - qCDebug(lcActivity) << "Error successfully added to the notification list: " << type << activity._message << activity._subject << activity._syncResultStatus << activity._syncFileItemStatus; - auto modifiedActivity = activity; - if (type == ErrorType::NetworkError) { - modifiedActivity._subject = tr("Network error occurred: client will retry syncing."); + auto shouldAddError = false; + + switch (type) + { + case ErrorType::NetworkError: + if (_durationSinceDisconnection.isValid() && _durationSinceDisconnection.hasExpired(3 * 60 *1000)) { + shouldAddError = true; + } + break; + case ErrorType::SyncError: + shouldAddError = true; + break; + } + + if (shouldAddError) { + qCDebug(lcActivity) << "Error successfully added to the notification list: " << type << activity._message << activity._subject << activity._syncResultStatus << activity._syncFileItemStatus; + auto modifiedActivity = activity; + if (type == ErrorType::NetworkError) { + modifiedActivity._subject = tr("Network error occurred: client will retry syncing."); + } + addEntriesToActivityList({modifiedActivity}); + _notificationErrorsLists.prepend(modifiedActivity); } - addEntriesToActivityList({modifiedActivity}); - _notificationErrorsLists.prepend(modifiedActivity); } void ActivityListModel::addIgnoredFileToList(const Activity &newActivity) diff --git a/src/gui/tray/activitylistmodel.h b/src/gui/tray/activitylistmodel.h index 6c88901ff..dfb4287f4 100644 --- a/src/gui/tray/activitylistmodel.h +++ b/src/gui/tray/activitylistmodel.h @@ -128,7 +128,7 @@ public slots: void slotTriggerDismiss(const int activityIndex); void addNotificationToActivityList(const OCC::Activity &activity); - void addErrorToActivityList(const OCC::Activity &activity, const ErrorType type); + void addErrorToActivityList(const OCC::Activity &activity, const OCC::ActivityListModel::ErrorType type); void addIgnoredFileToList(const OCC::Activity &newActivity); void addSyncFileItemToActivityList(const OCC::Activity &activity); void removeActivityFromActivityList(int row); diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 353035fb6..e714b2bd8 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -117,7 +117,7 @@ public slots: void slotItemCompleted(const QString &folder, const OCC::SyncFileItemPtr &item); void slotProgressInfo(const QString &folder, const OCC::ProgressInfo &progress); void slotAddError(const QString &folderAlias, const QString &message, OCC::ErrorCategory category); - void slotAddErrorToGui(const QString &folderAlias, const OCC::SyncFileItem::Status status, const QString &errorMessage, const QString &subject, const ErrorCategory category); + void slotAddErrorToGui(const QString &folderAlias, const OCC::SyncFileItem::Status status, const QString &errorMessage, const QString &subject, const OCC::ErrorCategory category); void slotNotificationRequestFinished(int statusCode); void slotNotifyNetworkError(QNetworkReply *reply); void slotEndNotificationRequest(int replyCode); diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 2edd3c4c5..dfff585f2 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -1153,6 +1153,13 @@ void PropagateDownloadFile::downloadFinished() ASSERT(!_tmpFile.isOpen()); const auto filename = propagator()->fullLocalPath(_item->_file); + // In case of file name clash, report an error + // This can happen if another parallel download saved a clashing file. + if (propagator()->localFileNameClash(_item->_file)) { + done(SyncFileItem::FileNameClash, tr("File %1 cannot be saved because of a local file name clash!").arg(QDir::toNativeSeparators(_item->_file)), ErrorCategory::GenericError); + return; + } + if (_item->_modtime <= 0) { FileSystem::remove(_tmpFile.fileName()); done(SyncFileItem::NormalError, tr("File %1 has invalid modified time reported by server. Do not save it.").arg(QDir::toNativeSeparators(_item->_file)), ErrorCategory::GenericError); diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index 33b4c334e..ca08042ee 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -629,7 +629,7 @@ void PropagateUploadFileCommon::slotPollFinished() finalize(); } -void PropagateUploadFileCommon::done(SyncFileItem::Status status, const QString &errorString, const ErrorCategory category) +void PropagateUploadFileCommon::done(const SyncFileItem::Status status, const QString &errorString, const ErrorCategory category) { _finished = true; PropagateItemJob::done(status, errorString, category); diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index 3c0aec4cc..f2c947ce6 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -281,7 +281,7 @@ private slots: void slotPollFinished(); protected: - void done(SyncFileItem::Status status, const QString &errorString = QString(), const ErrorCategory category = ErrorCategory::NoError) override; + void done(const SyncFileItem::Status status, const QString &errorString = QString(), const ErrorCategory category = ErrorCategory::NoError) override; /** * Aborts all running network jobs, except for the ones that mayAbortJob