]> git.proxmox.com Git - pve-zsync.git/commitdiff
Check whether job has been disabled while waiting/syncing
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 10 Oct 2019 09:55:17 +0000 (11:55 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 11 Oct 2019 09:51:16 +0000 (11:51 +0200)
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@proxmox.com>
pve-zsync

index abaa225b4cdd20c6064f04f56b36a3acd2b971b1..d14a1c165a998b333c91f849bbff14e189e0249d 100755 (executable)
--- 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);
            }