tape: create tmp dirs early at server startup

This commit is contained in:
Dietmar Maurer
2021-02-19 17:49:50 +01:00
parent aca4c2b5a9
commit cd44fb8d84
4 changed files with 49 additions and 11 deletions

View File

@ -463,10 +463,12 @@ fn save_changer_state_cache(
changer: &str,
state: &MtxStatus,
) -> Result<(), Error> {
let mut path = PathBuf::from("/run/proxmox-backup/changer-state");
std::fs::create_dir_all(&path)?;
let mut path = PathBuf::from(crate::tape::CHANGER_STATE_DIR);
path.push(changer);
let state = serde_json::to_string_pretty(state)?;
let backup_user = crate::backup::backup_user()?;
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0644);
let options = CreateOptions::new()
@ -474,8 +476,6 @@ fn save_changer_state_cache(
.owner(backup_user.uid)
.group(backup_user.gid);
let state = serde_json::to_string_pretty(state)?;
replace_file(path, state.as_bytes(), options)
}