public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] fix #3976: api/backup: make schedule/starttime truly optional on update
@ 2022-04-01  6:14 Dominik Csapak
  2022-04-01 15:54 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-04-01  6:14 UTC (permalink / raw)
  To: pve-devel

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>
---
 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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH manager] fix #3976: api/backup: make schedule/starttime truly optional on update
  2022-04-01  6:14 [pve-devel] [PATCH manager] fix #3976: api/backup: make schedule/starttime truly optional on update Dominik Csapak
@ 2022-04-01 15:54 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-04-01 15:54 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 01.04.22 08:14, Dominik Csapak wrote:
> 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>
> ---
>  PVE/API2/Backup.pm | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
>

applied, thanks!

albeit the "$required" param name made me ask "required what?", but as the
check fn is "private" and small enough I don't think its a real code smell
issue.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-01 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01  6:14 [pve-devel] [PATCH manager] fix #3976: api/backup: make schedule/starttime truly optional on update Dominik Csapak
2022-04-01 15:54 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal