From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] fix #3976: api/backup: make schedule/starttime truly optional on update
Date: Fri, 1 Apr 2022 08:14:13 +0200 [thread overview]
Message-ID: <20220401061413.702998-1-d.csapak@proxmox.com> (raw)
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
next reply other threads:[~2022-04-01 6:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 6:14 Dominik Csapak [this message]
2022-04-01 15:54 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220401061413.702998-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox