Consider isActiveFor() for process also when systemd unavailable

This commit is contained in:
Martchus 2018-04-02 20:50:59 +02:00
parent 146d4870e4
commit ce7a4421fa
3 changed files with 26 additions and 6 deletions

View File

@ -57,6 +57,10 @@ void SyncthingNotifier::handleStatusChangedEvent(SyncthingStatus newStatus)
m_previousStatus = newStatus;
}
/*!
* \brief Returns whether a "disconnected" notification should be shown.
* \todo Unify with InternalError::isRelevant().
*/
bool SyncthingNotifier::isDisconnectRelevant() const
{
// skip disconnect if not initialized
@ -74,20 +78,28 @@ bool SyncthingNotifier::isDisconnectRelevant() const
return false;
}
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
const SyncthingService &service(syncthingService());
if (m_service.isManuallyStopped()) {
return false;
}
#endif
// ignore inavailability after start or standby-wakeup
if (m_ignoreInavailabilityAfterStart) {
if (m_process.isRunning() && !m_service.isActiveWithoutSleepFor(m_process.activeSince(), m_ignoreInavailabilityAfterStart)) {
if (m_process.isRunning()
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
&& ((m_service.isSystemdAvailable() && !service.isActiveWithoutSleepFor(m_process.activeSince(), m_ignoreInavailabilityAfterStart))
|| !m_process.isActiveFor(m_ignoreInavailabilityAfterStart))
#else
&& !m_process.isActiveFor(m_ignoreInavailabilityAfterStart)
#endif
) {
return false;
}
if (m_service.isRunning() && !m_service.isActiveWithoutSleepFor(m_ignoreInavailabilityAfterStart)) {
return false;
}
}
#endif
return true;
}

View File

@ -14,6 +14,7 @@ namespace QtGui {
/*!
* \brief Returns whether the error is relevant. Only in this case a notification for the error should be shown.
* \todo Unify with SyncthingNotifier::isDisconnectRelevant().
*/
bool InternalError::isRelevant(const SyncthingConnection &connection, SyncthingErrorCategory category, int networkError)
{
@ -45,17 +46,24 @@ bool InternalError::isRelevant(const SyncthingConnection &connection, SyncthingE
if (settings.systemd.considerForReconnect && remoteHostClosed && service.isManuallyStopped()) {
return false;
}
#endif
// ignore inavailability after start or standby-wakeup
if (settings.ignoreInavailabilityAfterStart && networkError == QNetworkReply::ConnectionRefusedError) {
if (process.isRunning() && !service.isActiveWithoutSleepFor(process.activeSince(), settings.ignoreInavailabilityAfterStart)) {
if (process.isRunning()
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
&& ((service.isSystemdAvailable() && !service.isActiveWithoutSleepFor(process.activeSince(), settings.ignoreInavailabilityAfterStart))
|| !process.isActiveFor(settings.ignoreInavailabilityAfterStart))
#else
&& !process.isActiveFor(settings.ignoreInavailabilityAfterStart)
#endif
) {
return false;
}
if (service.isRunning() && !service.isActiveWithoutSleepFor(settings.ignoreInavailabilityAfterStart)) {
return false;
}
}
#endif
return true;
}

View File

@ -63,7 +63,7 @@
<item>
<widget class="QRadioButton" name="dbusRadioButton">
<property name="text">
<string>D-Bus notifi&amp;cations (org.freedesktop.Notifications)</string>
<string>D-Bus &amp;notifications (org.freedesktop.Notifications)</string>
</property>
</widget>
</item>
@ -86,7 +86,7 @@
<item>
<widget class="QLabel" name="ignoreInavailabilityAfterStartLabel">
<property name="text">
<string>Ignore inavailability of Syncthing the specified number of seconds after Syncthing has been started; has only effect if the Syncthing start can be determined which is currently only supported for the local instance by checking Systemd unit status</string>
<string>Ignore inavailability of Syncthing the specified number of seconds after Syncthing has been started; has only effect if the Syncthing start can be determined which is currently only supported for the local instance started via Systemd or the internal launcher.</string>
</property>
<property name="wordWrap">
<bool>true</bool>