From fd88d7ff2119fca0cfb1891b05494dae735f7399 Mon Sep 17 00:00:00 2001 From: yfprojects <62463991+real-yfprojects@users.noreply.github.com> Date: Sun, 3 Jul 2022 19:41:27 +0000 Subject: [PATCH] Fix seconds and microseconds for fixed schedule and fix scheduling for the same day. (#1368) Previously the seconds of the current time or the last backup time were be copied. Fixes #1363. This also fixes an issue when the scheduled time was missed and the backup is scheduled for the current day although the time of day set has already passed. * src/vorta/scheduler.py (VortaScheduler.set_timer_for_profile) --- src/vorta/scheduler.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/vorta/scheduler.py b/src/vorta/scheduler.py index 79443e21..79698b34 100644 --- a/src/vorta/scheduler.py +++ b/src/vorta/scheduler.py @@ -246,17 +246,19 @@ def set_timer_for_profile(self, profile_id: int): # calculate next scheduled time if profile.schedule_mode == 'interval': - last_time = last_run_log.end_time + last_time: dt = last_run_log.end_time interval = {profile.schedule_interval_unit: profile.schedule_interval_count} next_time = last_time + timedelta(**interval) elif profile.schedule_mode == 'fixed': - last_time = last_run_log.end_time + timedelta(days=1) + last_time = last_run_log.end_time next_time = last_time.replace( hour=profile.schedule_fixed_hour, - minute=profile.schedule_fixed_minute) + minute=profile.schedule_fixed_minute, + second=0, + microsecond=0) + timedelta(days=1) else: # unknown schedule mode @@ -286,14 +288,16 @@ def set_timer_for_profile(self, profile_id: int): next_time += timedelta(**interval) elif profile.schedule_mode == 'fixed': - if next_time.date() == dt.now().date(): + # schedule for today + next_time = dt.now().replace( + hour=profile.schedule_fixed_hour, + minute=profile.schedule_fixed_minute, + second=0, + microsecond=0) + + if next_time <= dt.now(): # time for today has passed, schedule for tomorrow next_time += timedelta(days=1) - else: - # schedule for today - next_time = dt.now().replace( - hour=profile.schedule_fixed_hour, - minute=profile.schedule_fixed_minute) # start QTimer timer_ms = (next_time - dt.now()).total_seconds() * 1000