[pve-devel] [PATCH v4 pve-zsync 4/4] Check whether job has been disabled while waiting/syncing
Fabian Ebner
f.ebner at proxmox.com
Thu Oct 10 11:55:17 CEST 2019
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 <f.ebner at proxmox.com>
---
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);
}
--
2.20.1
More information about the pve-devel
mailing list