Skip to content

Commit

Permalink
Fix whitespace handling in instance names
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed May 6, 2024
1 parent 1977dde commit 50c2552
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/core/processor/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
};
}

Expand Down Expand Up @@ -80,7 +84,7 @@ pub fn apply_addition(snapshot: AddedSnapshot, tree: &mut Tree, vfs: &Vfs) -> Re
vfs: &Vfs,
) -> Result<Option<Meta>> {
if let Err(err) = verify_name(&snapshot.name) {
bad_name!(err);
bad_name!(snapshot.name, err);
return Ok(None);
}

Expand Down Expand Up @@ -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(());
}

Expand Down
4 changes: 0 additions & 4 deletions src/syncback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 50c2552

Please sign in to comment.