1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

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)
This commit is contained in:
yfprojects 2022-07-03 19:41:27 +00:00 committed by GitHub
parent 305db92d4a
commit fd88d7ff21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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():
# 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)
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)
# start QTimer
timer_ms = (next_time - dt.now()).total_seconds() * 1000