mirror of
https://github.com/borgbase/vorta
synced 2024-12-22 07:43:09 +00:00
Fix setting a timer value too large for C++ int. (#1230)
Fixes #1227. Set timer only if value is smaller than `2**31-1` = 2147483647 else do nothing. Every 15 min vorta will trigger a reschedule.
This commit is contained in:
parent
0a78bd5342
commit
0c2fabd28c
1 changed files with 15 additions and 8 deletions
|
@ -149,17 +149,24 @@ def set_timer_for_profile(self, profile_id: int):
|
|||
minute=profile.schedule_fixed_minute)
|
||||
|
||||
# start QTimer
|
||||
logger.debug('Scheduling next run for %s', next_time)
|
||||
|
||||
timer_ms = (next_time - dt.now()).total_seconds() * 1000
|
||||
|
||||
timer = QtCore.QTimer()
|
||||
timer.setSingleShot(True)
|
||||
timer.setInterval(int(timer_ms))
|
||||
timer.timeout.connect(lambda: self.create_backup(profile_id))
|
||||
timer.start()
|
||||
if timer_ms < 2**31 - 1:
|
||||
logger.debug('Scheduling next run for %s', next_time)
|
||||
|
||||
self.timers[profile_id] = {'qtt': timer, 'dt': next_time}
|
||||
timer = QtCore.QTimer()
|
||||
timer.setSingleShot(True)
|
||||
timer.setInterval(int(timer_ms))
|
||||
timer.timeout.connect(lambda: self.create_backup(profile_id))
|
||||
timer.start()
|
||||
|
||||
self.timers[profile_id] = {'qtt': timer, 'dt': next_time}
|
||||
else:
|
||||
# int to big to pass it to qt which expects a c++ int
|
||||
# wait 15 min for regular reschedule
|
||||
logger.debug(
|
||||
f"Couldn't schedule for {next_time} because" +
|
||||
f"timer value {timer_ms} too large.")
|
||||
|
||||
# Emit signal so that e.g. the GUI can react to the new schedule
|
||||
self.schedule_changed.emit(profile_id)
|
||||
|
|
Loading…
Reference in a new issue