[pbs-devel] [PATCH proxmox-backup 2/3] cleanup: replace id from do_sync_job with info from job

Dominik Csapak d.csapak at proxmox.com
Thu Aug 13 14:30:18 CEST 2020


we already have it inside the job itself

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/admin/sync.rs          |  2 +-
 src/api2/pull.rs                | 11 +++++------
 src/bin/proxmox-backup-proxy.rs |  2 +-
 src/config/jobstate.rs          |  8 ++++++++
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/api2/admin/sync.rs b/src/api2/admin/sync.rs
index aafd808f..0985e26f 100644
--- a/src/api2/admin/sync.rs
+++ b/src/api2/admin/sync.rs
@@ -90,7 +90,7 @@ fn run_sync_job(
     let mut job = Job::new("syncjob", &id)?;
     job.load()?;
 
-    let upid_str = do_sync_job(&id, sync_job, &userid, None, job)?;
+    let upid_str = do_sync_job(job, sync_job, &userid, None)?;
 
     Ok(upid_str)
 }
diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index e8eb35e1..fc13cf40 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -66,19 +66,18 @@ pub async fn get_pull_parameters(
 }
 
 pub fn do_sync_job(
-    id: &str,
+    mut job: Job,
     sync_job: SyncJobConfig,
     userid: &Userid,
     schedule: Option<String>,
-    mut job: Job,
 ) -> Result<String, Error> {
 
-    let job_id = id.to_string();
-    let worker_type = "syncjob";
+    let job_id = job.jobname().to_string();
+    let worker_type = job.jobtype().to_string();
 
     let upid_str = WorkerTask::spawn(
-        worker_type,
-        Some(id.to_string()),
+        &worker_type,
+        Some(job.jobname().to_string()),
         userid.clone(),
         false,
         move |worker| async move {
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index c7f8bc79..1a30bc6f 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -548,7 +548,7 @@ async fn schedule_datastore_sync_jobs() {
 
         let userid = Userid::backup_userid().clone();
 
-        if let Err(err) = do_sync_job(&job_id, job_config, &userid, Some(event_str), job) {
+        if let Err(err) = do_sync_job(job, job_config, &userid, Some(event_str)) {
             eprintln!("unable to start datastore sync job {} - {}", &job_id, err);
         }
     }
diff --git a/src/config/jobstate.rs b/src/config/jobstate.rs
index 94566bb7..8931563b 100644
--- a/src/config/jobstate.rs
+++ b/src/config/jobstate.rs
@@ -232,6 +232,14 @@ impl Job {
         self.write_state()
     }
 
+    pub fn jobtype(&self) -> &str {
+        &self.jobtype
+    }
+
+    pub fn jobname(&self) -> &str {
+        &self.jobname
+    }
+
     fn write_state(&mut self) -> Result<(), Error> {
         let serialized = serde_json::to_string(&self.state)?;
         let path = get_path(&self.jobtype, &self.jobname);
-- 
2.20.1






More information about the pbs-devel mailing list