Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Discover
Commits
d607e0c6
Commit
d607e0c6
authored
Feb 07, 2022
by
Aleix Pol Gonzalez
🐧
Browse files
notifier: Make sure we don't trigger offline updates too often
parent
86d2c7aa
Pipeline
#134623
passed with stage
in 53 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
kcm/updatessettings.kcfg
View file @
d607e0c6
...
...
@@ -14,5 +14,6 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<entry
name=
"UseUnattendedUpdates"
type=
"Bool"
>
<default>
false
</default>
</entry>
<entry
name=
"LastUnattendedTrigger"
type=
"DateTime"
/>
</group>
</kcfg>
notifier/DiscoverNotifier.h
View file @
d607e0c6
...
...
@@ -18,6 +18,7 @@
class
KNotification
;
class
QNetworkConfigurationManager
;
class
UnattendedUpdates
;
class
UpdatesSettings
;
class
DiscoverNotifier
:
public
QObject
{
...
...
@@ -65,6 +66,10 @@ public:
{
return
m_isBusy
;
}
UpdatesSettings
*
settings
()
const
{
return
m_settings
;
}
public
Q_SLOTS
:
void
recheckSystemUpdateNeeded
();
...
...
@@ -95,7 +100,7 @@ private:
QPointer
<
KNotification
>
m_updatesAvailableNotification
;
UnattendedUpdates
*
m_unattended
=
nullptr
;
KConfigWatcher
::
Ptr
m_settingsWatcher
;
class
UpdatesSettings
*
m_settings
;
UpdatesSettings
*
m_settings
;
};
#endif // ABSTRACTKDEDMODULE_H
notifier/UnattendedUpdates.cpp
View file @
d607e0c6
...
...
@@ -6,6 +6,7 @@
#include
"UnattendedUpdates.h"
#include
"DiscoverNotifier.h"
#include
"updatessettings.h"
#include
<KIdleTime>
#include
<QDateTime>
#include
<QDebug>
...
...
@@ -28,13 +29,27 @@ UnattendedUpdates::~UnattendedUpdates() noexcept
void
UnattendedUpdates
::
checkNewState
()
{
using
namespace
std
::
chrono_literals
;
DiscoverNotifier
*
notifier
=
static_cast
<
DiscoverNotifier
*>
(
parent
());
// Only allow offline updating every 3h. It should keep some peace to our users, especially on rolling distros
const
QDateTime
updateableTime
=
notifier
->
settings
()
->
lastUnattendedTrigger
().
addSecs
((
3h
).
count
());
if
(
updateableTime
>
QDateTime
::
currentDateTimeUtc
())
{
qDebug
()
<<
"skipping update, already updated on"
<<
notifier
->
settings
()
->
lastUnattendedTrigger
().
toString
();
return
;
}
if
(
!
KIdleTime
::
instance
()
->
idleTimeouts
().
isEmpty
())
{
qDebug
()
<<
"already waiting for an idle time"
;
return
;
}
if
(
notifier
->
hasUpdates
())
{
qDebug
()
<<
"waiting for an idle moment"
;
// If the system is untouched for 1 hour, trigger the unattened update
using
namespace
std
::
chrono_literals
;
// If the system is untouched for 15 minutes, trigger the unattened update
KIdleTime
::
instance
()
->
addIdleTimeout
(
int
(
std
::
chrono
::
milliseconds
(
15min
).
count
()));
}
else
{
qDebug
()
<<
"nothing to do"
;
KIdleTime
::
instance
()
->
removeAllIdleTimeouts
();
}
}
...
...
@@ -56,6 +71,7 @@ void UnattendedUpdates::triggerUpdate()
DiscoverNotifier
*
notifier
=
static_cast
<
DiscoverNotifier
*>
(
parent
());
notifier
->
setBusy
(
false
);
process
->
deleteLater
();
notifier
->
settings
()
->
setLastUnattendedTrigger
(
QDateTime
::
currentDateTimeUtc
());
});
notifier
->
setBusy
(
true
);
...
...
Aleix Pol Gonzalez
🐧
@apol
mentioned in commit
6257e21c
·
Feb 08, 2022
mentioned in commit
6257e21c
mentioned in commit 6257e21c313e21afd80d101d24c78d66621236b1
Toggle commit list
Fabian Vogt
@fvogt
mentioned in merge request
!254 (merged)
·
Feb 09, 2022
mentioned in merge request
!254 (merged)
mentioned in merge request !254
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment