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.csa...@proxmox.com>
---
 PVE/API2/Backup.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index 76175f16..5d36789a 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -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;
            }
 
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to