[pbs-devel] [PATCH v3 proxmox-backup 1/3] prune job: prune job creation in separate function

Stefan Lendl s.lendl at proxmox.com
Thu Nov 23 17:38:45 CET 2023


move logic for prune job creation to do_create_prune_job

Tested-by: Gabriel Goller <g.goller at proxmox.com>
Signed-off-by: Stefan Lendl <s.lendl at 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(&section_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(&section_config)?;
-
-    crate::server::jobstate::create_state_file("prunejob", &config.id)?;
-
-    Ok(())
+    do_create_prune_job(config)
 }
 
 #[api(
-- 
2.42.0






More information about the pbs-devel mailing list