Remove duplicated status recalculation
This commit is contained in:
parent
9817be858d
commit
0ef2bf919a
|
@ -273,7 +273,7 @@ private Q_SLOTS:
|
|||
void readRestart();
|
||||
void readShutdown();
|
||||
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 readDevRejected(ChronoUtilities::DateTime eventTime, const QString &devId, const QJsonObject &eventData);
|
||||
void readCompletion();
|
||||
|
|
|
@ -937,9 +937,7 @@ void SyncthingConnection::readDirStatus()
|
|||
return;
|
||||
}
|
||||
|
||||
if (readDirSummary(DateTime::gmtNow(), replyDoc.object(), *dir, index)) {
|
||||
recalculateStatus();
|
||||
}
|
||||
readDirSummary(DateTime::gmtNow(), replyDoc.object(), *dir, index);
|
||||
|
||||
if (m_keepPolling) {
|
||||
concludeConnection();
|
||||
|
@ -1251,10 +1249,10 @@ void SyncthingConnection::readPostConfig()
|
|||
/*!
|
||||
* \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) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// update status
|
||||
bool stateChanged = false;
|
||||
const QString state(summary.value(QLatin1String("state")).toString());
|
||||
if (!state.isEmpty()) {
|
||||
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 &) {
|
||||
// FIXME: warning about invalid stateChanged
|
||||
}
|
||||
|
@ -1303,7 +1299,6 @@ bool SyncthingConnection::readDirSummary(DateTime eventTime, const QJsonObject &
|
|||
if (neededStats.isNull() && previouslyUpdated && (neededStats != previouslyNeeded || globalStats != previouslyGlobal)) {
|
||||
emit dirCompleted(eventTime, dir, index);
|
||||
}
|
||||
return stateChanged;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -82,20 +82,20 @@ bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, DateTime t
|
|||
globalError.clear();
|
||||
}
|
||||
|
||||
// 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:;
|
||||
}
|
||||
status = newStatus;
|
||||
return true;
|
||||
if (newStatus == status) {
|
||||
return false;
|
||||
}
|
||||
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