BackupDir: fix manifest_lock_path

this definitely shouldn't rely on BackupDir's Display implementation..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-05-16 10:39:10 +02:00 committed by Thomas Lamprecht
parent 1afce610c7
commit f2fe00f1e2
1 changed files with 6 additions and 5 deletions

View File

@ -421,13 +421,14 @@ impl BackupDir {
/// Returns the filename to lock a manifest
///
/// Also creates the basedir. The lockfile is located in
/// '/run/proxmox-backup/locks/{datastore}/{type}/{id}/{timestamp}.index.json.lck'
fn manifest_lock_path(&self) -> Result<String, Error> {
let mut path = format!("/run/proxmox-backup/locks/{}/{self}", self.store.name());
/// '/run/proxmox-backup/locks/{datastore}/[ns/{ns}/]+{type}/{id}/{timestamp}.index.json.lck'
fn manifest_lock_path(&self) -> Result<PathBuf, Error> {
let mut path = PathBuf::from(&format!("/run/proxmox-backup/locks/{}", self.store.name()));
path.push(self.relative_path());
std::fs::create_dir_all(&path)?;
use std::fmt::Write;
let ts = self.backup_time_string();
write!(path, "/{ts}{}", &MANIFEST_LOCK_NAME)?;
path.push(&format!("{ts}{MANIFEST_LOCK_NAME}"));
Ok(path)
}