diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c331d..d29c056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.9.3] - 2023-02-12 + +### Fixed + +- Issue where rotz would create empty symlinks if the source file does not exist + ## [0.9.2] - 2023-01-18 ### Fixed @@ -192,7 +198,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Dotfile linking - Error handling -[Unreleased]: https://github.com/volllly/rotz/compare/v0.9.2...HEAD +[Unreleased]: https://github.com/volllly/rotz/compare/v0.9.3...HEAD +[0.9.3]: https://github.com/volllly/rotz/releases/tag/v0.9.3 [0.9.2]: https://github.com/volllly/rotz/releases/tag/v0.9.2 [0.9.1]: https://github.com/volllly/rotz/releases/tag/v0.9.1 [0.9.0]: https://github.com/volllly/rotz/releases/tag/v0.9.0 diff --git a/Cargo.lock b/Cargo.lock index 0ec4d21..37ca022 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1630,7 +1630,7 @@ dependencies = [ [[package]] name = "rotz" -version = "0.9.2" +version = "0.9.3" dependencies = [ "baker", "clap", diff --git a/Cargo.toml b/Cargo.toml index 4b9b21c..c3f9230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rotz" -version = "0.9.2" +version = "0.9.3" edition = "2021" authors = ["Paul Volavsek "] license = "MIT" diff --git a/src/commands/link.rs b/src/commands/link.rs index ad0a7de..c3be9cd 100644 --- a/src/commands/link.rs +++ b/src/commands/link.rs @@ -36,6 +36,10 @@ enum Error { #[error("The file \"{0}\" already exists")] #[diagnostic(code(link::already_exists), help("Try using the --force flag"))] AlreadyExists(PathBuf), + + #[error("The link source file \"{0}\" does not exist exists")] + #[diagnostic(code(link::does_not_exist), help("Maybe you have a typo in the filename?"))] + LinkSourceDoesNotExist(PathBuf), } pub(crate) struct Link<'a> { @@ -161,6 +165,10 @@ impl<'a> Command for Link<'a> { #[cfg_attr(feature = "profiling", instrument)] fn create_link(from: &Path, to: &Path, link_type: &LinkType, force: bool, linked: Option<&HashMap>) -> std::result::Result<(), Error> { + if !from.exists() { + return Error::LinkSourceDoesNotExist(from.to_path_buf()).pipe(Err); + } + let create: fn(&Path, &Path) -> std::result::Result<(), std::io::Error> = if link_type.is_symbolic() { symlink } else { hardlink }; match create(from, to) {