From 34ec8966b270a9f43b9487444c8aba08b84ecc42 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sun, 14 Nov 2021 07:03:29 +0000 Subject: [PATCH] Refuse to overwrite pointer names when generated from timestamps --- datman/src/commands/backup.rs | 7 ++++++- datman/src/remote/backup_source_requester.rs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/datman/src/commands/backup.rs b/datman/src/commands/backup.rs index dacf555..f679d0d 100644 --- a/datman/src/commands/backup.rs +++ b/datman/src/commands/backup.rs @@ -157,7 +157,9 @@ pub fn backup_source_to_destination( }; let pointer_name = get_pointer_name_at(&source_name, Utc::now()); - + if pile.read_pointer(pointer_name.as_str())?.is_some() { + bail!("Pointer by name {:?} already exists; refusing to overwrite.", pointer_name); + } info!("Will write as pointer {:?}.", pointer_name); info!("Searching for suitable parents."); @@ -218,6 +220,9 @@ pub fn backup_source_to_destination( let pile = open_pile(&absolute_dest_path, &pile_descriptor)?; let pointer_name = get_pointer_name_at(&source_name, Utc::now()); + if pile.read_pointer(pointer_name.as_str())?.is_some() { + bail!("Pointer by name {:?} already exists; refusing to overwrite.", pointer_name); + } info!("Will write as pointer {:?}.", pointer_name); let mut chunker = yama::chunking::RecursiveChunker::new(SENSIBLE_THRESHOLD, &pile); diff --git a/datman/src/remote/backup_source_requester.rs b/datman/src/remote/backup_source_requester.rs index 68611ac..7165687 100644 --- a/datman/src/remote/backup_source_requester.rs +++ b/datman/src/remote/backup_source_requester.rs @@ -182,7 +182,9 @@ pub fn backup_remote_source_to_destination let pile = open_pile(&absolute_dest_path, &pile_descriptor)?; let pointer_name = get_pointer_name_at(&source_name, Utc::now()); - + if pile.read_pointer(pointer_name.as_str())?.is_some() { + bail!("Pointer by name {:?} already exists; refusing to overwrite.", pointer_name); + } info!("Will write as pointer {:?}.", pointer_name); info!("Searching for suitable parents.");