fix #3976: api/backup: make schedule/starttime truly optional on update

on create we require either starttime (+dow) or a schedule, but when
updating an existing job, this is not necessary

before we changed to schedules, the starttime was not optional either on
update, but i think there is no reason to require the user to send the
schedule/startime along every time.

the gui will send all values every time, so that was never a problem there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-04-01 08:14:13 +02:00 committed by Thomas Lamprecht
parent d0477f12ad
commit 81ba0803d5

View File

@ -62,13 +62,14 @@ my $convert_to_schedule = sub {
};
my $schedule_param_check = sub {
my ($param) = @_;
my ($param, $required) = @_;
if (defined($param->{schedule})) {
if (defined($param->{starttime})) {
raise_param_exc({ starttime => "'starttime' and 'schedule' cannot both be set" });
}
} elsif (!defined($param->{starttime})) {
raise_param_exc({ schedule => "neither 'starttime' nor 'schedule' were set" });
raise_param_exc({ schedule => "neither 'starttime' nor 'schedule' were set" })
if $required;
} else {
$param->{schedule} = $convert_to_schedule->($param);
}
@ -201,7 +202,7 @@ __PACKAGE__->register_method({
$rpcenv->check($user, "/pool/$pool", ['VM.Backup']);
}
$schedule_param_check->($param);
$schedule_param_check->($param, 1);
$param->{enabled} = 1 if !defined($param->{enabled});
@ -448,7 +449,7 @@ __PACKAGE__->register_method({
}
my $schedule_updated = 0;
if ($param->{schedule} ne $job->{schedule}) {
if (defined($param->{schedule}) && $param->{schedule} ne $job->{schedule}) {
$schedule_updated = 1;
}