Consider directories still out-of-sync if there are pull errors
Syncthing can report an "idle" status despite pull errors. This still means the directory is out-of-sync. With this change the out-of-sync status is only cleared when reading a "FolderSummary" event without pull errors (or temporarily if the directory is e.g. scanning).
This commit is contained in:
parent
fdc73bed60
commit
1acfb8c896
|
@ -1418,8 +1418,14 @@ void SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &
|
|||
dir.lastStatisticsUpdate = eventTime;
|
||||
|
||||
// update status
|
||||
if (const auto state = summary.value(QLatin1String("state")).toString(); !state.isEmpty()) {
|
||||
dir.assignStatus(state, parseTimeStamp(summary.value(QLatin1String("stateChanged")), QStringLiteral("state changed"), dir.lastStatusUpdate));
|
||||
const auto lastStatusUpdate = parseTimeStamp(summary.value(QLatin1String("stateChanged")), QStringLiteral("state changed"), dir.lastStatusUpdate);
|
||||
if (dir.pullErrorCount) {
|
||||
// consider the directory still as out-of-sync if there are still pull errors
|
||||
// note: Syncthing can report an "idle" status despite pull errors.
|
||||
dir.status = SyncthingDirStatus::OutOfSync;
|
||||
dir.lastStatusUpdate = std::max(dir.lastStatusUpdate, lastStatusUpdate);
|
||||
} else if (const auto state = summary.value(QLatin1String("state")).toString(); !state.isEmpty()) {
|
||||
dir.assignStatus(state, lastStatusUpdate);
|
||||
}
|
||||
|
||||
dir.completionPercentage = globalStats.bytes ? static_cast<int>((globalStats.bytes - neededStats.bytes) * 100 / globalStats.bytes) : 100;
|
||||
|
|
|
@ -80,6 +80,13 @@ bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, DateTime t
|
|||
globalError.clear();
|
||||
}
|
||||
|
||||
// consider the directory still as out-of-sync if there are still pull errors
|
||||
// note: Syncthing reports status changes to "idle" despite pull errors. This means we can only rely on reading
|
||||
// a "FolderSummary" event without pull errors for clearing the out-of-sync status.
|
||||
if (pullErrorCount && (newStatus == SyncthingDirStatus::Unknown || newStatus == SyncthingDirStatus::Idle)) {
|
||||
newStatus = SyncthingDirStatus::OutOfSync;
|
||||
}
|
||||
|
||||
if (newStatus == status) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue