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 <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2022-10-11 16:10:53 +02:00 committed by Matthieu Gallien
parent 431ccfec5a
commit 0e002f35f4
6 changed files with 33 additions and 10 deletions

View 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)

View 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);

View 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);

View 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);

View 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);

View 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