cleanup: replace id from do_sync_job with info from job

we already have it inside the job itself

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-08-13 14:30:18 +02:00 committed by Dietmar Maurer
parent 77bd2a469c
commit 713b66b6ed
4 changed files with 15 additions and 8 deletions

View File

@ -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)
}

View File

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

View File

@ -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);
}
}

View File

@ -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);