From 98b556b61c5327198e5c2ff5b2c05f1f97c7b805 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Thu, 10 Oct 2019 11:55:17 +0200 Subject: [PATCH] Check whether job has been disabled while waiting/syncing There are two new checks that allow disabling a job while it is 'syncing' or 'waiting'. Previously when sync finished it would re-enable such a job involuntarily. Disabling a 'waiting' job causes it to not sync anymore. Signed-off-by: Fabian Ebner --- pve-zsync | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pve-zsync b/pve-zsync index abaa225..d14a1c1 100755 --- a/pve-zsync +++ b/pve-zsync @@ -612,6 +612,10 @@ sub sync { #job might've changed while we waited for the sync lock, but we can be sure it's not syncing eval { $job = get_job($param); }; + if ($job && defined($job->{state}) && $job->{state} eq "stopped") { + die "Job --source $param->{source} --name $param->{name} has been disabled\n"; + } + $dest = parse_target($param->{dest}); $source = parse_target($param->{source}); @@ -675,7 +679,11 @@ sub sync { locked("$CONFIG_PATH/cron_and_state.lock", sub { eval { $job = get_job($param); }; if ($job) { - $job->{state} = "ok"; + if (defined($job->{state}) && $job->{state} eq "stopped") { + $job->{state} = "stopped"; + } else { + $job->{state} = "ok"; + } $job->{lsync} = $date; update_state($job); }