Improve handling folder errors
This commit is contained in:
parent
7b0dd785c2
commit
9b92b72bfd
|
@ -1163,7 +1163,12 @@ void SyncthingConnection::readDirEvent(DateTime eventTime, const QString &eventT
|
|||
if(find(errors.cbegin(), errors.cend(), dirError) == errors.cend()) {
|
||||
errors.emplace_back(move(dirError));
|
||||
dirInfo->assignStatus(SyncthingDirStatus::OutOfSync, eventTime);
|
||||
emitNotification(eventTime, dirInfo->errors.back().message);
|
||||
|
||||
// emit newNotification() for new errors
|
||||
auto &previousErrors = dirInfo->previousErrors;
|
||||
if(find(previousErrors.cbegin(), previousErrors.cend(), dirInfo->errors.back()) == previousErrors.cend()) {
|
||||
emitNotification(eventTime, dirInfo->errors.back().message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,14 @@ bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateT
|
|||
} else if(statusStr == QLatin1String("scanning")) {
|
||||
newStatus = SyncthingDirStatus::Scanning;
|
||||
} else if(statusStr == QLatin1String("syncing")) {
|
||||
// ensure status changed signal is emitted
|
||||
if(!errors.empty()) {
|
||||
errors.clear(); // errors become obsolete
|
||||
status = SyncthingDirStatus::Unknown; // ensure status changed signal is emitted
|
||||
status = SyncthingDirStatus::Unknown;
|
||||
}
|
||||
// errors become obsolete; however errors must be kept as previous errors to be able
|
||||
// to identify new errors occuring during this sync attempt as known errors
|
||||
previousErrors.clear();
|
||||
previousErrors.swap(errors);
|
||||
newStatus = SyncthingDirStatus::Synchronizing;
|
||||
} else if(statusStr == QLatin1String("error")) {
|
||||
progressPercentage = 0;
|
||||
|
|
|
@ -73,6 +73,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir
|
|||
int progressPercentage = 0;
|
||||
int progressRate = 0;
|
||||
std::vector<SyncthingDirError> errors;
|
||||
std::vector<SyncthingDirError> previousErrors;
|
||||
int globalBytes = 0, globalDeleted = 0, globalFiles = 0;
|
||||
int localBytes = 0, localDeleted = 0, localFiles = 0;
|
||||
int neededByted = 0, neededFiles = 0;
|
||||
|
|
|
@ -127,6 +127,8 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
return QColor(Qt::red);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
return dir.errors.empty() ? QColor(Qt::gray) : QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -229,7 +231,7 @@ int SyncthingDirectoryModel::rowCount(const QModelIndex &parent) const
|
|||
if(!parent.isValid()) {
|
||||
return static_cast<int>(m_dirs.size());
|
||||
} else if(!parent.parent().isValid()) {
|
||||
return parent.parent().row() >= 0 && static_cast<size_t>(parent.parent().row()) < m_dirs.size() && m_dirs[static_cast<size_t>(parent.parent().row())].errors.empty() ? 6 : 7;
|
||||
return 8;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,6 +264,7 @@ void SyncthingDirectoryModel::dirStatusChanged(const SyncthingDir &, int index)
|
|||
emit dataChanged(modelIndex1, modelIndex1, QVector<int>() << Qt::DecorationRole);
|
||||
const QModelIndex modelIndex2(this->index(index, 1, QModelIndex()));
|
||||
emit dataChanged(modelIndex2, modelIndex2, QVector<int>() << Qt::DisplayRole << Qt::ForegroundRole);
|
||||
emit dataChanged(this->index(0, 1, modelIndex1), this->index(7, 1, modelIndex1), QVector<int>() << Qt::DisplayRole);
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
|
Loading…
Reference in New Issue