Ignore old FolderCompletion events
This commit is contained in:
parent
eb1ec29992
commit
c4d63e0e7c
|
@ -1651,7 +1651,7 @@ void SyncthingConnection::readDirEvent(DateTime eventTime, const QString &eventT
|
|||
dirInfo->completionPercentage = percentage;
|
||||
emit dirStatusChanged(*dirInfo, index);
|
||||
if (percentage == 100) {
|
||||
emit dirCompleted(*dirInfo, index);
|
||||
emit dirCompleted(eventTime, *dirInfo, index);
|
||||
}
|
||||
}
|
||||
} else if (eventType == QLatin1String("FolderScanProgress")) {
|
||||
|
|
|
@ -160,7 +160,7 @@ Q_SIGNALS:
|
|||
void dirStatusChanged(const SyncthingDir &dir, int index);
|
||||
void devStatusChanged(const SyncthingDev &dev, int index);
|
||||
void downloadProgressChanged();
|
||||
void dirCompleted(const SyncthingDir &dir, int index, const SyncthingDev *remoteDev = nullptr);
|
||||
void dirCompleted(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev = nullptr);
|
||||
void newNotification(ChronoUtilities::DateTime when, const QString &message);
|
||||
void error(const QString &errorMessage, SyncthingErrorCategory category, int networkError, const QNetworkRequest &request = QNetworkRequest(),
|
||||
const QByteArray &response = QByteArray());
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include "./syncthingservice.h"
|
||||
#endif
|
||||
|
||||
#include <c++utilities/chrono/datetime.h>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
/*!
|
||||
|
@ -14,10 +18,6 @@ namespace Data {
|
|||
*
|
||||
* In contrast to the signals provided by the SyncthingConnection class, these signals take further apply
|
||||
* further logic and take additional information into account (previous status, service status if known, ...).
|
||||
*
|
||||
* \remarks Not tested yet. Supposed to simplify
|
||||
* - SyncthingApplet::handleConnectionStatusChanged(SyncthingStatus status)
|
||||
* - and TrayIcon::showStatusNotification(SyncthingStatus status).
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -59,6 +59,7 @@ void SyncthingNotifier::handleStatusChangedEvent(SyncthingStatus newStatus)
|
|||
*/
|
||||
void SyncthingNotifier::emitConnectedAndDisconnected(SyncthingStatus newStatus)
|
||||
{
|
||||
// discard event if not enabled
|
||||
if (!(m_enabledNotifications & SyncthingHighLevelNotification::ConnectedDisconnected)) {
|
||||
return;
|
||||
}
|
||||
|
@ -87,15 +88,22 @@ void SyncthingNotifier::emitConnectedAndDisconnected(SyncthingStatus newStatus)
|
|||
/*!
|
||||
* \brief Emits the syncComplete() signal.
|
||||
*/
|
||||
void SyncthingNotifier::emitSyncComplete(const SyncthingDir &dir, int index, const SyncthingDev *remoteDev)
|
||||
void SyncthingNotifier::emitSyncComplete(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev)
|
||||
{
|
||||
VAR_UNUSED(index)
|
||||
VAR_UNUSED(remoteDev)
|
||||
|
||||
// discard event if not enabled
|
||||
if ((m_enabledNotifications & SyncthingHighLevelNotification::SyncComplete) == 0 || !m_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// discard event if too old so we don't get "sync complete" messages for all dirs on startup
|
||||
if ((DateTime::gmtNow() - when) > TimeSpan::fromSeconds(5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// format the notification message
|
||||
const auto message(syncCompleteString(std::vector<const SyncthingDir *>{ &dir }));
|
||||
if (!message.isEmpty()) {
|
||||
emit syncComplete(message);
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
namespace ChronoUtilities {
|
||||
class DateTime;
|
||||
}
|
||||
|
||||
namespace Data {
|
||||
|
||||
enum class SyncthingStatus;
|
||||
|
@ -67,7 +71,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
void emitConnectedAndDisconnected(SyncthingStatus newStatus);
|
||||
void emitSyncComplete(const SyncthingDir &dir, int index, const SyncthingDev *remoteDev);
|
||||
void emitSyncComplete(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev);
|
||||
|
||||
const SyncthingConnection &m_connection;
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
|
|
Loading…
Reference in New Issue