5
0
mirror of git://git.proxmox.com/git/pve-zsync.git synced 2025-02-08 09:57:56 +03:00

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 <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2019-10-10 11:55:17 +02:00 committed by Thomas Lamprecht
parent 8ab5db491f
commit 98b556b61c

View File

@ -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);
}