datastore/prune schedules: use JobState for tracking of schedules
like the sync jobs, so that if an admin configures a schedule it really starts the next time that time is reached not immediately Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
9d3f183ba9
commit
9866de5e3d
@ -131,6 +131,8 @@ pub fn create_datastore(param: Value) -> Result<(), Error> {
|
||||
|
||||
datastore::save_config(&config)?;
|
||||
|
||||
crate::config::jobstate::create_state_file("prune", &datastore.name)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -312,7 +314,11 @@ pub fn update_datastore(
|
||||
}
|
||||
|
||||
if gc_schedule.is_some() { data.gc_schedule = gc_schedule; }
|
||||
if prune_schedule.is_some() { data.prune_schedule = prune_schedule; }
|
||||
let mut prune_schedule_changed = false;
|
||||
if prune_schedule.is_some() {
|
||||
prune_schedule_changed = true;
|
||||
data.prune_schedule = prune_schedule;
|
||||
}
|
||||
if verify_schedule.is_some() { data.verify_schedule = verify_schedule; }
|
||||
|
||||
if keep_last.is_some() { data.keep_last = keep_last; }
|
||||
@ -326,6 +332,12 @@ pub fn update_datastore(
|
||||
|
||||
datastore::save_config(&config)?;
|
||||
|
||||
// we want to reset the statefile, to avoid an immediate sync in some cases
|
||||
// (e.g. going from monthly to weekly in the second week of the month)
|
||||
if prune_schedule_changed {
|
||||
crate::config::jobstate::create_state_file("prune", &name)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -365,6 +377,8 @@ pub fn delete_datastore(name: String, digest: Option<String>) -> Result<(), Erro
|
||||
|
||||
datastore::save_config(&config)?;
|
||||
|
||||
crate::config::jobstate::remove_state_file("prune", &name)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user