Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist: Don't let errors become warnings #5516 #5865

Merged
merged 1 commit into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gui/protocolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ QTreeWidgetItem *ProtocolWidget::createCompletedTreewidgetItem(const QString &fo

QIcon icon;
if (item._status == SyncFileItem::NormalError
|| item._status == SyncFileItem::FatalError) {
|| item._status == SyncFileItem::FatalError
|| item._status == SyncFileItem::BlacklistedError) {
icon = Theme::instance()->syncStateIcon(SyncResult::Error);
} else if (Progress::isWarningKind(item._status)) {
icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ static void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item)
// An ignoreDuration of 0 mean we're tracking the error, but not actively
// suppressing it.
if (item._hasBlacklistEntry && newEntry._ignoreDuration > 0) {
item._status = SyncFileItem::FileIgnored;
item._errorString.prepend(PropagateItemJob::tr("Continue blacklisting:") + " ");
item._status = SyncFileItem::BlacklistedError;

qCInfo(lcPropagator) << "blacklisting " << item._file
<< " for " << newEntry._ignoreDuration
Expand Down Expand Up @@ -260,6 +259,7 @@ void PropagateItemJob::done(SyncFileItem::Status statusArg, const QString &error
case SyncFileItem::Conflict:
case SyncFileItem::FileIgnored:
case SyncFileItem::NoStatus:
case SyncFileItem::BlacklistedError:
// nothing
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libsync/progressdispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ bool Progress::isWarningKind(SyncFileItem::Status kind)
{
return kind == SyncFileItem::SoftError || kind == SyncFileItem::NormalError
|| kind == SyncFileItem::FatalError || kind == SyncFileItem::FileIgnored
|| kind == SyncFileItem::Conflict || kind == SyncFileItem::Restoration;
|| kind == SyncFileItem::Conflict || kind == SyncFileItem::Restoration
|| kind == SyncFileItem::BlacklistedError;
}

bool Progress::isIgnoredKind(SyncFileItem::Status kind)
Expand Down
16 changes: 12 additions & 4 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,20 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item)
}
}

int waitSeconds = entry._lastTryTime + entry._ignoreDuration - now;
qCInfo(lcEngine) << "Item is on blacklist: " << entry._file
<< "retries:" << entry._retryCount
<< "for another" << (entry._lastTryTime + entry._ignoreDuration - now) << "s";
item._instruction = CSYNC_INSTRUCTION_ERROR;
item._status = SyncFileItem::FileIgnored;
item._errorString = tr("The item is not synced because of previous errors: %1").arg(entry._errorString);
<< "for another" << waitSeconds << "s";

// We need to indicate that we skip this file due to blacklisting
// for reporting and for making sure we don't update the blacklist
// entry yet.
// Classification is this _instruction and _status
item._instruction = CSYNC_INSTRUCTION_IGNORE;
item._status = SyncFileItem::BlacklistedError;

auto waitSecondsStr = Utility::durationToDescriptiveString1(1000 * waitSeconds);
item._errorString = tr("%1 (skipped due to earlier error, trying again in %2)").arg(entry._errorString, waitSecondsStr);

return true;
}
Expand Down
13 changes: 11 additions & 2 deletions src/libsync/syncfileitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SyncFileItem
SoftLink = CSYNC_FTW_TYPE_SLINK
};

enum Status {
enum Status { // stored in 4 bits
NoStatus,

FatalError, ///< Error that causes the sync to stop
Expand All @@ -63,7 +63,16 @@ class SyncFileItem
Success, ///< The file was properly synced
Conflict, ///< The file was properly synced, but a conflict was created
FileIgnored, ///< The file is in the ignored list (or blacklisted with no retries left)
Restoration ///< The file was restored because what should have been done was not allowed
Restoration, ///< The file was restored because what should have been done was not allowed

/** For files whose errors were blacklisted.
*
* If _instruction == IGNORE, the file wasn't even reattempted.
*
* These errors should usually be shown as NormalErrors, but not be as loud
* as them.
*/
BlacklistedError
};

SyncFileItem()
Expand Down
1 change: 1 addition & 0 deletions src/libsync/syncfilestatustracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static inline bool showErrorInSocketApi(const SyncFileItem &item)
return item._instruction == CSYNC_INSTRUCTION_ERROR
|| status == SyncFileItem::NormalError
|| status == SyncFileItem::FatalError
|| status == SyncFileItem::BlacklistedError
|| item._hasBlacklistEntry;
}

Expand Down