api2/pull: extend do_sync_job to also handle schedule and jobstate

so that we can log if triggered by a schedule, and writing to a jobstatefile
also correctly polls now the abort_future of the worker, so that
users can stop a sync

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-08-13 10:29:18 +02:00
committed by Dietmar Maurer
parent 42b68f72e6
commit 02543a5c7f
2 changed files with 54 additions and 17 deletions

View File

@ -9,7 +9,7 @@ use crate::api2::types::*;
use crate::api2::pull::do_sync_job;
use crate::config::sync::{self, SyncJobStatus, SyncJobConfig};
use crate::server::UPID;
use crate::config::jobstate::JobState;
use crate::config::jobstate::{Job, JobState};
use crate::tools::systemd::time::{
parse_calendar_event, compute_next_event};
@ -87,7 +87,10 @@ fn run_sync_job(
let userid: Userid = rpcenv.get_user().unwrap().parse()?;
let upid_str = do_sync_job(&id, sync_job, &userid)?;
let mut job = Job::new("syncjob", &id)?;
job.load()?;
let upid_str = do_sync_job(&id, sync_job, &userid, None, job)?;
Ok(upid_str)
}