Skip to content

Commit

Permalink
Improved error message. Added proper subject. Removed folder name fro…
Browse files Browse the repository at this point in the history
…m a message text.

Signed-off-by: allexzander <blackslayer4@gmail.com>
  • Loading branch information
allexzander committed Jun 14, 2021
1 parent 6b590be commit adc08d4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ void Folder::slotSyncError(const QString &message, ErrorCategory category)
emit ProgressDispatcher::instance()->syncError(alias(), message, category);
}

void Folder::slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage)
void Folder::slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject)
{
emit ProgressDispatcher::instance()->addErrorToGui(alias() , status, errorMessage);
emit ProgressDispatcher::instance()->addErrorToGui(alias(), status, errorMessage, subject);
}

void Folder::slotSyncStarted()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private slots:
*/
void slotSyncError(const QString &message, ErrorCategory category = ErrorCategory::Normal);

void slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage);
void slotAddErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject = {});

void slotTransmissionProgress(const ProgressInfo &pi);
void slotItemCompleted(const SyncFileItemPtr &);
Expand Down
7 changes: 4 additions & 3 deletions src/gui/tray/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace {
constexpr qint64 expiredActivitiesCheckIntervalMs = 1000 * 60;
constexpr qint64 activityDefaultExpirationTimeMs = 1000 * 60 * 2;
}

namespace OCC {
Expand Down Expand Up @@ -443,7 +444,7 @@ void User::slotAddError(const QString &folderAlias, const QString &message, Erro
}
}

void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage)
void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage, const QString &subject)
{
const auto folderInstance = FolderMan::instance()->folder(folderAlias);
if (!folderInstance)
Expand All @@ -457,8 +458,8 @@ void User::slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status st
activity._status = status;
const auto currentDateTime = QDateTime::currentDateTime();
activity._dateTime = QDateTime::fromString(currentDateTime.toString(), Qt::ISODate);
activity._expireAtMsecs = currentDateTime.addSecs(60 * 1).toMSecsSinceEpoch();
activity._subject = folderInstance->shortGuiLocalPath();
activity._expireAtMsecs = currentDateTime.addMSecs(activityDefaultExpirationTimeMs).toMSecsSinceEpoch();
activity._subject = !subject.isEmpty() ? subject : folderInstance->shortGuiLocalPath();
activity._message = errorMessage;
activity._link = folderInstance->shortGuiLocalPath();
activity._accName = folderInstance->accountState()->account()->displayName();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/UserModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public slots:
void slotItemCompleted(const QString &folder, const SyncFileItemPtr &item);
void slotProgressInfo(const QString &folder, const ProgressInfo &progress);
void slotAddError(const QString &folderAlias, const QString &message, ErrorCategory category);
void slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage);
void slotAddErrorToGui(const QString &folderAlias, SyncFileItem::Status status, const QString &errorMessage, const QString &subject = {});
void slotNotificationRequestFinished(int statusCode);
void slotNotifyNetworkError(QNetworkReply *reply);
void slotEndNotificationRequest(int replyCode);
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,13 +921,13 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
// 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 %1. It's going to get wiped!").arg(path._local));
emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading a folder. It's going to get wiped!"), path._local);
}
} else {
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 %1. Those, conflicted, are going to get wiped!").arg(path._local));
emit _discoveryData->addErrorToGui(SyncFileItem::SoftError, tr("Conflict when uploading some files to a folder. Those, conflicted, are going to get wiped!"), path._local);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class DiscoveryPhase : public QObject
*/
void silentlyExcluded(const QString &folderPath);

void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage);
void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject);
};

/// Implementation of DiscoveryPhase::adjustRenamedPath
Expand Down
3 changes: 2 additions & 1 deletion src/libsync/progressdispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,9 @@ class OWNCLOUDSYNC_EXPORT ProgressDispatcher : public QObject
* @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);
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
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
/// 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);
void addErrorToGui(SyncFileItem::Status status, const QString &errorMessage, const QString &subject);

void finished(bool success);
void started();
Expand Down

0 comments on commit adc08d4

Please sign in to comment.