From 50c25526b0b6bc4b1ccaa93d48aaa5bc98e6b632 Mon Sep 17 00:00:00 2001 From: Dervex Date: Mon, 6 May 2024 09:09:24 +0200 Subject: [PATCH] Fix whitespace handling in instance names --- CHANGELOG.md | 5 +++++ src/core/processor/write.rs | 12 ++++++++---- src/syncback.rs | 4 ---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b5f08..8eb06ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +### Fixed + +- Instances with whitespace characters are now now synced back properly +- Instances with corrupted names now log the proper error message + ## [2.0.4] - 2024-05-05 ### Added diff --git a/src/core/processor/write.rs b/src/core/processor/write.rs index 0e5b3cd..b049529 100644 --- a/src/core/processor/write.rs +++ b/src/core/processor/write.rs @@ -32,8 +32,12 @@ macro_rules! path_exists { } macro_rules! bad_name { - ($err:expr) => { - argon_error!("Instance name is corrupted: {}", $err); + ($name:expr, $err:expr) => { + argon_error!( + "Instance with name: {} is corrupted: {}! Skipping..", + $name.bold(), + $err + ); }; } @@ -80,7 +84,7 @@ pub fn apply_addition(snapshot: AddedSnapshot, tree: &mut Tree, vfs: &Vfs) -> Re vfs: &Vfs, ) -> Result> { if let Err(err) = verify_name(&snapshot.name) { - bad_name!(err); + bad_name!(snapshot.name, err); return Ok(None); } @@ -446,7 +450,7 @@ pub fn apply_update(snapshot: UpdatedSnapshot, tree: &mut Tree, vfs: &Vfs) -> Re // It has to be done after updating properties as it may change the file path if let Some(name) = snapshot.name { if let Err(err) = verify_name(&name) { - bad_name!(err); + bad_name!(name, err); return Ok(()); } diff --git a/src/syncback.rs b/src/syncback.rs index 6934e43..ae587f6 100644 --- a/src/syncback.rs +++ b/src/syncback.rs @@ -39,10 +39,6 @@ pub fn verify_name(name: &str) -> Result<()> { bail!("file name cannot contain {} character", char.to_string().bold()); } - if char.is_whitespace() { - bail!("file name cannot contain whitespace"); - } - #[cfg(windows)] if char.is_control() { bail!("file name cannot contain ASCII control characters");