Don't meld 'unshared' into the status
Just deal with it like with the paused flag. This will hopefully solve the issue that dirs are wrongly shown as unshared till the next status update.
This commit is contained in:
parent
5a80089cbd
commit
ad3c8b5240
|
@ -931,7 +931,6 @@ bool Application::checkWhetherIdle() const
|
|||
switch (dir.dirObj->status) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
case SyncthingDirStatus::Idle:
|
||||
case SyncthingDirStatus::Unshared:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -18,8 +18,6 @@ QString statusString(SyncthingDirStatus status)
|
|||
return QCoreApplication::translate("SyncthingDirStatus", "unknown");
|
||||
case SyncthingDirStatus::Idle:
|
||||
return QCoreApplication::translate("SyncthingDirStatus", "idle");
|
||||
case SyncthingDirStatus::Unshared:
|
||||
return QCoreApplication::translate("SyncthingDirStatus", "unshared");
|
||||
case SyncthingDirStatus::Scanning:
|
||||
return QCoreApplication::translate("SyncthingDirStatus", "scanning");
|
||||
case SyncthingDirStatus::Synchronizing:
|
||||
|
@ -57,15 +55,12 @@ bool SyncthingDir::checkWhetherStatusUpdateRelevant(DateTime time)
|
|||
|
||||
bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus)
|
||||
{
|
||||
// check whether out-of-sync or unshared
|
||||
// check whether out-of-sync
|
||||
switch (newStatus) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
case SyncthingDirStatus::Idle:
|
||||
case SyncthingDirStatus::Unshared:
|
||||
if (!itemErrors.empty()) {
|
||||
newStatus = SyncthingDirStatus::OutOfSync;
|
||||
} else if (deviceIds.empty()) {
|
||||
newStatus = SyncthingDirStatus::Unshared;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
|
@ -143,6 +138,8 @@ QString SyncthingDir::statusString() const
|
|||
{
|
||||
if (paused) {
|
||||
return QCoreApplication::translate("SyncthingDir", "paused");
|
||||
} else if (isUnshared()) {
|
||||
return QCoreApplication::translate("SyncthingDir", "unshared");
|
||||
} else {
|
||||
return ::Data::statusString(status);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Data {
|
||||
|
||||
enum class SyncthingDirStatus { Unknown, Idle, Unshared, Scanning, Synchronizing, OutOfSync };
|
||||
enum class SyncthingDirStatus { Unknown, Idle, Scanning, Synchronizing, OutOfSync };
|
||||
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT statusString(SyncthingDirStatus status);
|
||||
|
||||
|
@ -122,6 +122,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
QStringRef pathWithoutTrailingSlash() const;
|
||||
bool isLocallyUpToDate() const;
|
||||
bool areRemotesUpToDate() const;
|
||||
bool isUnshared() const;
|
||||
|
||||
QString id;
|
||||
QString label;
|
||||
|
@ -183,6 +184,11 @@ inline bool SyncthingDir::isLocallyUpToDate() const
|
|||
return neededStats.isNull();
|
||||
}
|
||||
|
||||
inline bool SyncthingDir::isUnshared() const
|
||||
{
|
||||
return deviceIds.empty() && (status == SyncthingDirStatus::Idle || status == SyncthingDirStatus::Unknown);
|
||||
}
|
||||
|
||||
inline bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time)
|
||||
{
|
||||
return checkWhetherStatusUpdateRelevant(time) && finalizeStatusUpdate(newStatus);
|
||||
|
|
|
@ -74,6 +74,36 @@
|
|||
"disableTempIndexes": false,
|
||||
"fsync": false,
|
||||
"invalid": ""
|
||||
},
|
||||
{
|
||||
"id": "forever-alone",
|
||||
"label": "A folder which is not shared",
|
||||
"path": "...",
|
||||
"type": "readwrite",
|
||||
"devices": [],
|
||||
"rescanIntervalS": 60,
|
||||
"ignorePerms": false,
|
||||
"autoNormalize": true,
|
||||
"minDiskFreePct": 1,
|
||||
"versioning": {
|
||||
"type": "simple",
|
||||
"params": {
|
||||
"keep": "10"
|
||||
}
|
||||
},
|
||||
"copiers": 0,
|
||||
"pullers": 0,
|
||||
"hashers": 0,
|
||||
"order": "random",
|
||||
"ignoreDelete": false,
|
||||
"scanProgressIntervalS": 0,
|
||||
"pullerSleepS": 0,
|
||||
"pullerPauseS": 0,
|
||||
"maxConflicts": 10,
|
||||
"disableSparseFiles": false,
|
||||
"disableTempIndexes": false,
|
||||
"fsync": false,
|
||||
"invalid": ""
|
||||
}
|
||||
],
|
||||
"devices": [
|
||||
|
|
|
@ -182,16 +182,18 @@ void MiscTests::testConnectionSettingsAndLoadingSelfSignedCert()
|
|||
void MiscTests::testSyncthingDir()
|
||||
{
|
||||
SyncthingDir dir;
|
||||
dir.deviceIds << QStringLiteral("dev1") << QStringLiteral("dev2");
|
||||
dir.status = SyncthingDirStatus::Unknown;
|
||||
|
||||
DateTime updateTime(DateTime::fromDate(2005, 2, 3));
|
||||
CPPUNIT_ASSERT(dir.assignStatus(SyncthingDirStatus::Unshared, updateTime));
|
||||
CPPUNIT_ASSERT(dir.assignStatus(SyncthingDirStatus::Idle, updateTime));
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("unshared"), dir.statusString());
|
||||
CPPUNIT_ASSERT_EQUAL(updateTime, dir.lastStatusUpdate);
|
||||
|
||||
dir.deviceIds << QStringLiteral("dev1") << QStringLiteral("dev2");
|
||||
|
||||
CPPUNIT_ASSERT(!dir.assignStatus(SyncthingDirStatus::Scanning, DateTime::fromDate(2003, 6, 7)));
|
||||
CPPUNIT_ASSERT_EQUAL(updateTime, dir.lastStatusUpdate);
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("unshared"), dir.statusString());
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("idle"), dir.statusString());
|
||||
|
||||
const DateTime lastScanTime(DateTime::now());
|
||||
updateTime += TimeSpan::fromSeconds(5);
|
||||
|
|
|
@ -143,10 +143,11 @@ bool SyncthingDirActions::updateStatus(const SyncthingDir &dir)
|
|||
m_statusAction.setText(tr("Status: ") + dir.statusString());
|
||||
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
||||
m_statusAction.setIcon(statusIcons().pause);
|
||||
} else if (dir.isUnshared()) {
|
||||
m_statusAction.setIcon(statusIcons().disconnected);
|
||||
} else {
|
||||
switch (dir.status) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
case SyncthingDirStatus::Unshared:
|
||||
m_statusAction.setIcon(statusIcons().disconnected);
|
||||
break;
|
||||
case SyncthingDirStatus::Idle:
|
||||
|
|
|
@ -268,10 +268,11 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case 0:
|
||||
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
||||
return statusIcons().pause;
|
||||
} else if (dir.deviceIds.empty()) {
|
||||
return statusIcons().disconnected; // "unshared" status
|
||||
} else {
|
||||
switch (dir.status) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
case SyncthingDirStatus::Unshared:
|
||||
return statusIcons().disconnected;
|
||||
case SyncthingDirStatus::Idle:
|
||||
return statusIcons().idling;
|
||||
|
@ -378,11 +379,12 @@ QString SyncthingDirectoryModel::dirStatusString(const SyncthingDir &dir)
|
|||
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
||||
return tr("Paused");
|
||||
}
|
||||
if (dir.isUnshared()) {
|
||||
return tr("Unshared");
|
||||
}
|
||||
switch (dir.status) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
return tr("Unknown status");
|
||||
case SyncthingDirStatus::Unshared:
|
||||
return tr("Unshared");
|
||||
case SyncthingDirStatus::Idle:
|
||||
return tr("Idle");
|
||||
case SyncthingDirStatus::Scanning:
|
||||
|
@ -406,13 +408,14 @@ QVariant SyncthingDirectoryModel::dirStatusColor(const SyncthingDir &dir) const
|
|||
if (dir.paused && dir.status != SyncthingDirStatus::OutOfSync) {
|
||||
return QVariant();
|
||||
}
|
||||
if (dir.isUnshared()) {
|
||||
return Colors::orange(m_brightColors);
|
||||
}
|
||||
switch (dir.status) {
|
||||
case SyncthingDirStatus::Unknown:
|
||||
break;
|
||||
case SyncthingDirStatus::Idle:
|
||||
return Colors::green(m_brightColors);
|
||||
case SyncthingDirStatus::Unshared:
|
||||
return Colors::orange(m_brightColors);
|
||||
case SyncthingDirStatus::Scanning:
|
||||
case SyncthingDirStatus::Synchronizing:
|
||||
return Colors::blue(m_brightColors);
|
||||
|
|
Loading…
Reference in New Issue