From: Stefan Lendl <s.lendl@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v2 proxmox-backup 1/3] prune job: prune job creation in separate function
Date: Tue, 21 Nov 2023 17:21:09 +0100 [thread overview]
Message-ID: <20231121162111.537833-2-s.lendl@proxmox.com> (raw)
In-Reply-To: <20231121162111.537833-1-s.lendl@proxmox.com>
move logic for prune job creation to do_create_prune_job
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
---
src/api2/config/prune.rs | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/api2/config/prune.rs b/src/api2/config/prune.rs
index 6f391722..1e8b5526 100644
--- a/src/api2/config/prune.rs
+++ b/src/api2/config/prune.rs
@@ -56,6 +56,24 @@ pub fn list_prune_jobs(
Ok(list)
}
+pub fn do_create_prune_job(config: PruneJobConfig) -> Result<(), Error> {
+ let _lock = prune::lock_config()?;
+
+ let (mut section_config, _digest) = prune::config()?;
+
+ if section_config.sections.get(&config.id).is_some() {
+ param_bail!("id", "job '{}' already exists.", config.id);
+ }
+
+ section_config.set_data(&config.id, "prune", &config)?;
+
+ prune::save_config(§ion_config)?;
+
+ crate::server::jobstate::create_state_file("prunejob", &config.id)?;
+
+ Ok(())
+}
+
#[api(
protected: true,
input: {
@@ -81,21 +99,7 @@ pub fn create_prune_job(
user_info.check_privs(&auth_id, &config.acl_path(), PRIV_DATASTORE_MODIFY, true)?;
- let _lock = prune::lock_config()?;
-
- let (mut section_config, _digest) = prune::config()?;
-
- if section_config.sections.get(&config.id).is_some() {
- param_bail!("id", "job '{}' already exists.", config.id);
- }
-
- section_config.set_data(&config.id, "prune", &config)?;
-
- prune::save_config(§ion_config)?;
-
- crate::server::jobstate::create_state_file("prunejob", &config.id)?;
-
- Ok(())
+ do_create_prune_job(config)
}
#[api(
--
2.42.0
next prev parent reply other threads:[~2023-11-21 16:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 16:21 [pbs-devel] [PATCH v2 proxmox-backup 0/3] datastore: Create a prune job upon datastore creation Stefan Lendl
2023-11-21 16:21 ` Stefan Lendl [this message]
2023-11-21 16:21 ` [pbs-devel] [PATCH v2 proxmox-backup 2/3] pass worker context to do_create_prune_job Stefan Lendl
2023-11-21 16:21 ` [pbs-devel] [PATCH v2 proxmox-backup 3/3] fix #4374: create a prune job upon datastore creation Stefan Lendl
2023-11-22 9:24 ` [pbs-devel] [PATCH v2 proxmox-backup 0/3] datastore: Create " Gabriel Goller
2023-11-23 17:03 ` Stefan Lendl
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=20231121162111.537833-2-s.lendl@proxmox.com \
--to=s.lendl@proxmox.com \
--cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal