From 7e210bd0b4f35180dd971b66591057cbaa5ccb27 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 19 Dec 2019 06:49:03 +0100 Subject: [PATCH] src/backup/chunk_store.rs: create lock file with correct owner --- src/backup/chunk_store.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/backup/chunk_store.rs b/src/backup/chunk_store.rs index 9b402c58..844097e8 100644 --- a/src/backup/chunk_store.rs +++ b/src/backup/chunk_store.rs @@ -113,6 +113,10 @@ impl ChunkStore { bail!("unable to create chunk store '{}' subdir {:?} - {}", name, chunk_dir, err); } + // create lock file with correct owner/group + let lockfile_path = Self::lockfile_path(&base); + proxmox::tools::fs::replace_file(lockfile_path, b"", options.clone())?; + // create 64*1024 subdirs let mut last_percentage = 0; @@ -129,12 +133,22 @@ impl ChunkStore { } } + Self::open(name, base) } - pub fn open>(name: &str, path: P) -> Result { + fn lockfile_path>(base: P) -> PathBuf { + let base: PathBuf = base.into(); - let base: PathBuf = path.into(); + let mut lockfile_path = base.clone(); + lockfile_path.push(".lock"); + + lockfile_path + } + + pub fn open>(name: &str, base: P) -> Result { + + let base: PathBuf = base.into(); if !base.is_absolute() { bail!("expected absolute path - got {:?}", base); @@ -146,8 +160,7 @@ impl ChunkStore { bail!("unable to open chunk store '{}' at {:?} - {}", name, chunk_dir, err); } - let mut lockfile_path = base.clone(); - lockfile_path.push(".lock"); + let lockfile_path = Self::lockfile_path(&base); let locker = tools::ProcessLocker::new(&lockfile_path)?;