@@ -11,7 +11,9 @@ use tracing::{debug, info, instrument, warn};
1111use zbus:: { fdo:: Error as FdoError , interface, Connection , DBusError , SignalContext } ;
1212use zbus_systemd:: { login1, systemd1} ;
1313
14- use crate :: shutdown:: UnknownShutdownKind ;
14+ use crate :: {
15+ consts:: DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP , shutdown:: UnknownShutdownKind ,
16+ } ;
1517
1618/// The duration of time since the last "start signup" event that has to have passed
1719/// before the update agent is permitted to start a download.
@@ -39,6 +41,7 @@ impl BusError {
3941
4042pub struct Manager {
4143 duration_to_allow_downloads : Duration ,
44+ stop_core_after_signup : Duration ,
4245 last_signup_event : watch:: Sender < Instant > ,
4346 system_connection : Option < Connection > ,
4447}
@@ -58,6 +61,7 @@ impl Manager {
5861 ) ;
5962 Self {
6063 duration_to_allow_downloads,
64+ stop_core_after_signup : DURATION_TO_STOP_CORE_AFTER_LAST_SIGNUP ,
6165 last_signup_event : tx,
6266 system_connection : None ,
6367 }
@@ -74,6 +78,14 @@ impl Manager {
7478 }
7579 }
7680
81+ #[ must_use]
82+ pub fn stop_core_after_signup ( self , stop_core_after_signup : Duration ) -> Self {
83+ Self {
84+ stop_core_after_signup,
85+ ..self
86+ }
87+ }
88+
7789 #[ allow( clippy:: must_use_candidate) ]
7890 pub fn are_downloads_allowed ( & self ) -> bool {
7991 self . last_signup_event . borrow ( ) . elapsed ( ) >= self . duration_to_allow_downloads
@@ -143,6 +155,7 @@ impl Manager {
143155 crate :: tasks:: update:: spawn_shutdown_worldcoin_core_timer (
144156 systemd_proxy. clone ( ) ,
145157 self . last_signup_event . subscribe ( ) ,
158+ self . stop_core_after_signup ,
146159 ) ;
147160 // Wait for one second to see if worldcoin core is already shut down
148161 match tokio:: time:: timeout ( Duration :: from_secs ( 1 ) , & mut shutdown_core_task)
0 commit comments