config/jobstate: replace Job:load with create_state_file

it really is not necessary, since the only time we are interested in
loading the state from the file is when we list it, and there
we use JobState::load directly to avoid the lock

we still need to create the file on syncjob creation though, so
that we have the correct time for the schedule

to do this we add a new create_state_file that overwrites it on creation
of a syncjob

for safety, we subtract 30 seconds from the in-memory state in case
the statefile is missing

since we call create_state_file from  proxmox-backup-api,
we have to chown the lock file after creating to the backup user,
else the sync job scheduling cannot aquire the lock

also we remove the lock file on statefile removal

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

View File

@ -87,8 +87,7 @@ fn run_sync_job(
let userid: Userid = rpcenv.get_user().unwrap().parse()?;
let mut job = Job::new("syncjob", &id)?;
job.load()?;
let job = Job::new("syncjob", &id)?;
let upid_str = do_sync_job(job, sync_job, &userid, None)?;