Handle new/unknown dir status better

* Show the raw directory status from the Syncthing API if
  it is an unknown (maybe newly introduced) status value.
* Note that the same does not apply to the device status
  because the device status is only deduced from other
  information.
This commit is contained in:
Martchus 2019-09-21 16:28:08 +02:00
parent d9cf64fd91
commit 6724dfa89a
3 changed files with 13 additions and 2 deletions

View File

@ -93,6 +93,7 @@ bool SyncthingDir::assignStatus(const QString &statusStr, CppUtilities::DateTime
if (!checkWhetherStatusUpdateRelevant(time)) {
return false;
}
// identify statusStr
SyncthingDirStatus newStatus;
if (statusStr == QLatin1String("idle")) {
@ -112,6 +113,9 @@ bool SyncthingDir::assignStatus(const QString &statusStr, CppUtilities::DateTime
} else {
newStatus = SyncthingDirStatus::Idle;
}
rawStatus = statusStr;
return finalizeStatusUpdate(newStatus, time);
}
@ -136,6 +140,8 @@ QString SyncthingDir::statusString() const
return QCoreApplication::translate("SyncthingDir", "paused");
} else if (isUnshared()) {
return QCoreApplication::translate("SyncthingDir", "unshared");
} else if (status == SyncthingDirStatus::Unknown && !rawStatus.isEmpty()) {
return QString(rawStatus);
} else {
return ::Data::statusString(status);
}

View File

@ -171,6 +171,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
int blocksAlreadyDownloaded = 0;
int blocksToBeDownloaded = 0;
QString downloadLabel;
QString rawStatus;
unsigned int downloadPercentage = 0;
bool ignorePermissions = false;
bool ignoreDelete = false;
@ -214,7 +215,11 @@ inline bool SyncthingDir::isUnshared() const
inline bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, CppUtilities::DateTime time)
{
return checkWhetherStatusUpdateRelevant(time) && finalizeStatusUpdate(newStatus, time);
if (!checkWhetherStatusUpdateRelevant(time)) {
return false;
}
rawStatus.clear();
return finalizeStatusUpdate(newStatus, time);
}
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingOverallDirStatistics {

View File

@ -455,7 +455,7 @@ QString SyncthingDirectoryModel::dirStatusString(const SyncthingDir &dir)
}
switch (dir.status) {
case SyncthingDirStatus::Unknown:
return tr("Unknown status");
return dir.rawStatus.isEmpty() ? tr("Unknown status") : QString(dir.rawStatus);
case SyncthingDirStatus::Idle:
return tr("Idle");
case SyncthingDirStatus::Scanning: