]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
add more metadata to sync errors to allow filtering
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 11 Oct 2022 14:10:53 +0000 (16:10 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Wed, 28 Jun 2023 09:21:50 +0000 (11:21 +0200)
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 <matthieu.gallien@nextcloud.com>
src/gui/tray/activitylistmodel.cpp
src/gui/tray/activitylistmodel.h
src/gui/tray/usermodel.h
src/libsync/propagatedownload.cpp
src/libsync/propagateupload.cpp
src/libsync/propagateupload.h

index 4ff5595a807b96ac5cb91ffccdf887fa6e24851a..589a0a9c140017cdad9a5724c466eceee09cb81c 100644 (file)
@@ -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)
index 6c88901ff30b852bc9f8bd5a56260cf9fdcc7794..dfb4287f4f1873b01cb58f10b11f2535579c8a93 100644 (file)
@@ -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);
index 353035fb68ffe4e2962aeac6ebee0c4467df5f9e..e714b2bd8d5ccc2b7020d5ea74b5ae1800bfc164 100644 (file)
@@ -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);
index 2edd3c4c5ba8250440999565e3a2cd78b3d34af3..dfff585f2d39ad4f06a719bf0d9bdc7fd5de27b4 100644 (file)
@@ -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);
index 33b4c334e8fa8b18a9d8b77de7faebb28ed12ce2..ca08042eeaf208d884d96d417fb19a5f6a750eb8 100644 (file)
@@ -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);
index 3c0aec4cc11ca98815622f13ca757e1642e23b7a..f2c947ce689b685e821ae1e420888695b46d1e18 100644 (file)
@@ -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