Discard obsolete folder errors
* Discard folder errors older than the last "sync" state * Unfortunately we don't know the the time of the last sync from the beginning. To prevent showing obsolete errors in this state, discard all errors if the status changes to something other than "out-of-syn".
This commit is contained in:
parent
dd5cf12b1c
commit
25ae9266a8
|
@ -507,11 +507,12 @@ void SyncthingConnection::readDirs(const QJsonArray &dirs)
|
|||
dirItem->deviceNames.clear();
|
||||
for (const QJsonValueRef dev : dirObj.value(QLatin1String("devices")).toArray()) {
|
||||
const QString devId = dev.toObject().value(QLatin1String("deviceID")).toString();
|
||||
if (!devId.isEmpty() && devId != m_myId) {
|
||||
dirItem->deviceIds << devId;
|
||||
if (const SyncthingDev *const dev = findDevInfo(devId, dummy)) {
|
||||
dirItem->deviceNames << dev->name;
|
||||
}
|
||||
if (devId.isEmpty() || devId == m_myId) {
|
||||
continue;
|
||||
}
|
||||
dirItem->deviceIds << devId;
|
||||
if (const SyncthingDev *const dev = findDevInfo(devId, dummy)) {
|
||||
dirItem->deviceNames << dev->name;
|
||||
}
|
||||
}
|
||||
dirItem->assignDirType(dirObj.value(QLatin1String("type")).toString());
|
||||
|
@ -1751,6 +1752,9 @@ void SyncthingConnection::readFolderErrors(DateTime eventTime, const QJsonObject
|
|||
if (errors.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (dirInfo.lastSyncStarted > eventTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const QJsonValue &errorVal : errors) {
|
||||
const QJsonObject error(errorVal.toObject());
|
||||
|
|
|
@ -53,27 +53,41 @@ bool SyncthingDir::checkWhetherStatusUpdateRelevant(DateTime time)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus)
|
||||
bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, DateTime time)
|
||||
{
|
||||
// check whether out-of-sync
|
||||
// clear out-of-sync items
|
||||
switch (newStatus) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
case SyncthingDirStatus::Idle:
|
||||
if (!itemErrors.empty()) {
|
||||
newStatus = SyncthingDirStatus::OutOfSync;
|
||||
case SyncthingDirStatus::OutOfSync:
|
||||
break;
|
||||
default:
|
||||
if (newStatus == SyncthingDirStatus::Synchronizing || lastSyncStarted.isNull()) {
|
||||
// errors become obsolete; however errors must be kept as previous errors to be able
|
||||
// to identify "new errors" as known errors
|
||||
previousItemErrors.clear();
|
||||
previousItemErrors.swap(itemErrors);
|
||||
}
|
||||
}
|
||||
|
||||
// set time of the last "sync" state (used internally and not displayed, hence keep it GMT)
|
||||
switch (newStatus) {
|
||||
case SyncthingDirStatus::Synchronizing:
|
||||
lastSyncStarted = time;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
// clear global error if not out-of-sync anymore
|
||||
if (newStatus != SyncthingDirStatus::OutOfSync) {
|
||||
globalError.clear();
|
||||
}
|
||||
// actuall update the status ...
|
||||
|
||||
// update the status ...
|
||||
if (newStatus != status) {
|
||||
// ... and also update last scan time
|
||||
switch (status) {
|
||||
case SyncthingDirStatus::Scanning:
|
||||
// FIXME: better use \a time and convert it from GMT to local time
|
||||
lastScanTime = DateTime::now();
|
||||
break;
|
||||
default:;
|
||||
|
@ -105,10 +119,6 @@ bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateT
|
|||
if (!itemErrors.empty()) {
|
||||
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
|
||||
previousItemErrors.clear();
|
||||
previousItemErrors.swap(itemErrors);
|
||||
newStatus = SyncthingDirStatus::Synchronizing;
|
||||
} else if (statusStr == QLatin1String("error")) {
|
||||
completionPercentage = 0;
|
||||
|
@ -116,7 +126,7 @@ bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateT
|
|||
} else {
|
||||
newStatus = SyncthingDirStatus::Idle;
|
||||
}
|
||||
return finalizeStatusUpdate(newStatus);
|
||||
return finalizeStatusUpdate(newStatus, time);
|
||||
}
|
||||
|
||||
bool SyncthingDir::assignDirType(const QString &dirTypeStr)
|
||||
|
|
|
@ -144,8 +144,9 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
SyncthingDirType dirType = SyncthingDirType::Unknown;
|
||||
int rescanInterval = 0;
|
||||
int minDiskFreePercentage = 0;
|
||||
SyncthingDirStatus status = SyncthingDirStatus::Idle;
|
||||
SyncthingDirStatus status = SyncthingDirStatus::Unknown;
|
||||
ChronoUtilities::DateTime lastStatusUpdate;
|
||||
ChronoUtilities::DateTime lastSyncStarted;
|
||||
int completionPercentage = 0;
|
||||
int scanningPercentage = 0;
|
||||
double scanningRate = 0;
|
||||
|
@ -175,7 +176,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
|
||||
private:
|
||||
bool checkWhetherStatusUpdateRelevant(ChronoUtilities::DateTime time);
|
||||
bool finalizeStatusUpdate(SyncthingDirStatus newStatus);
|
||||
bool finalizeStatusUpdate(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time);
|
||||
};
|
||||
|
||||
inline SyncthingDir::SyncthingDir(const QString &id, const QString &label, const QString &path)
|
||||
|
@ -207,7 +208,7 @@ inline bool SyncthingDir::isUnshared() const
|
|||
|
||||
inline bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time)
|
||||
{
|
||||
return checkWhetherStatusUpdateRelevant(time) && finalizeStatusUpdate(newStatus);
|
||||
return checkWhetherStatusUpdateRelevant(time) && finalizeStatusUpdate(newStatus, time);
|
||||
}
|
||||
|
||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingOverallDirStatistics {
|
||||
|
|
Loading…
Reference in New Issue