Remove duplicated status recalculation
This commit is contained in:
parent
9817be858d
commit
0ef2bf919a
|
@ -273,7 +273,7 @@ private Q_SLOTS:
|
||||||
void readRestart();
|
void readRestart();
|
||||||
void readShutdown();
|
void readShutdown();
|
||||||
void readDirStatus();
|
void readDirStatus();
|
||||||
bool readDirSummary(ChronoUtilities::DateTime eventTime, const QJsonObject &summary, SyncthingDir &dirInfo, int index);
|
void readDirSummary(ChronoUtilities::DateTime eventTime, const QJsonObject &summary, SyncthingDir &dirInfo, int index);
|
||||||
void readDirRejected(ChronoUtilities::DateTime eventTime, const QString &dirId, const QJsonObject &eventData);
|
void readDirRejected(ChronoUtilities::DateTime eventTime, const QString &dirId, const QJsonObject &eventData);
|
||||||
void readDevRejected(ChronoUtilities::DateTime eventTime, const QString &devId, const QJsonObject &eventData);
|
void readDevRejected(ChronoUtilities::DateTime eventTime, const QString &devId, const QJsonObject &eventData);
|
||||||
void readCompletion();
|
void readCompletion();
|
||||||
|
|
|
@ -937,9 +937,7 @@ void SyncthingConnection::readDirStatus()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readDirSummary(DateTime::gmtNow(), replyDoc.object(), *dir, index)) {
|
readDirSummary(DateTime::gmtNow(), replyDoc.object(), *dir, index);
|
||||||
recalculateStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_keepPolling) {
|
if (m_keepPolling) {
|
||||||
concludeConnection();
|
concludeConnection();
|
||||||
|
@ -1251,10 +1249,10 @@ void SyncthingConnection::readPostConfig()
|
||||||
/*!
|
/*!
|
||||||
* \brief Reads data from requestDirStatus() and FolderSummary-event and stores them to \a dir.
|
* \brief Reads data from requestDirStatus() and FolderSummary-event and stores them to \a dir.
|
||||||
*/
|
*/
|
||||||
bool SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &summary, SyncthingDir &dir, int index)
|
void SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &summary, SyncthingDir &dir, int index)
|
||||||
{
|
{
|
||||||
if (summary.isEmpty() || dir.lastStatisticsUpdate > eventTime) {
|
if (summary.isEmpty() || dir.lastStatisticsUpdate > eventTime) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// backup previous statistics -> if there's no difference after all, don't emit completed event
|
// backup previous statistics -> if there's no difference after all, don't emit completed event
|
||||||
|
@ -1286,12 +1284,10 @@ bool SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &
|
||||||
dir.lastStatisticsUpdate = eventTime;
|
dir.lastStatisticsUpdate = eventTime;
|
||||||
|
|
||||||
// update status
|
// update status
|
||||||
bool stateChanged = false;
|
|
||||||
const QString state(summary.value(QLatin1String("state")).toString());
|
const QString state(summary.value(QLatin1String("state")).toString());
|
||||||
if (!state.isEmpty()) {
|
if (!state.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
stateChanged
|
dir.assignStatus(state, DateTime::fromIsoStringGmt(summary.value(QLatin1String("stateChanged")).toString().toUtf8().data()));
|
||||||
|= dir.assignStatus(state, DateTime::fromIsoStringGmt(summary.value(QLatin1String("stateChanged")).toString().toUtf8().data()));
|
|
||||||
} catch (const ConversionException &) {
|
} catch (const ConversionException &) {
|
||||||
// FIXME: warning about invalid stateChanged
|
// FIXME: warning about invalid stateChanged
|
||||||
}
|
}
|
||||||
|
@ -1303,7 +1299,6 @@ bool SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &
|
||||||
if (neededStats.isNull() && previouslyUpdated && (neededStats != previouslyNeeded || globalStats != previouslyGlobal)) {
|
if (neededStats.isNull() && previouslyUpdated && (neededStats != previouslyNeeded || globalStats != previouslyGlobal)) {
|
||||||
emit dirCompleted(eventTime, dir, index);
|
emit dirCompleted(eventTime, dir, index);
|
||||||
}
|
}
|
||||||
return stateChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -82,20 +82,20 @@ bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, DateTime t
|
||||||
globalError.clear();
|
globalError.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the status ...
|
if (newStatus == status) {
|
||||||
if (newStatus != status) {
|
return false;
|
||||||
// ... 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:;
|
|
||||||
}
|
|
||||||
status = newStatus;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
// update last scan time and status
|
||||||
|
switch (status) {
|
||||||
|
case SyncthingDirStatus::Scanning:
|
||||||
|
// FIXME: better use \a time and convert it from GMT to local time
|
||||||
|
lastScanTime = DateTime::now();
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
status = newStatus;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue