Skip to content

Commit

Permalink
🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly committed Feb 12, 2023
1 parent 9082758 commit 6673089
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rotz"
version = "0.9.2"
version = "0.9.3"
edition = "2021"
authors = ["Paul Volavsek <paul.volavsek@gmail.com>"]
license = "MIT"
Expand Down
8 changes: 8 additions & 0 deletions src/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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<PathBuf, PathBuf>>) -> 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) {
Expand Down

0 comments on commit 6673089

Please sign in to comment.