diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e47c8..8e85e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Force folders to end with an underscore if they would usually end with a space + or full stop, due to issues with NTFS (#11). + ## [0.3.1] - 2023-10-07 ### Fixed @@ -72,7 +79,7 @@ plan to add in the future. Initial public release of Bandsnatch. [unreleased]: https://github.com/Ovyerus/bandsnatch/compare/v0.3.1...HEAD -[0.3.1]: https://github.com/Ovyerus/bandsnatch/compare/v0.3.1 +[0.3.1]: https://github.com/Ovyerus/bandsnatch/releases/tag/v0.3.1 [0.3.0]: https://github.com/Ovyerus/bandsnatch/releases/tag/v0.3.0 [0.2.1]: https://github.com/Ovyerus/bandsnatch/releases/tag/v0.2.1 [0.2.0]: https://github.com/Ovyerus/bandsnatch/releases/tag/v0.2.0 diff --git a/flake.nix b/flake.nix index 1a9a297..7d298ff 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,10 @@ # TODO: cross compilation craneLib = crane.lib.${system}; - rust = pkgs.rust-bin.stable.latest.default; # TODO: lock + # TODO: lock + rust = pkgs.rust-bin.stable.latest.default.override { + extensions = ["rust-src"]; + }; stdenv = if pkgs.stdenv.isLinux diff --git a/src/util.rs b/src/util.rs index c40a61e..a04e1b3 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,7 +5,7 @@ use std::{ }; // From https://github.com/Ezwen/bandcamp-collection-downloader/blob/master/src/main/kotlin/bandcampcollectiondownloader/core/Constants.kt#L7 -static REPLACEMENT_CHARS: phf::Map<&'static str, &'static str> = phf_map! { +static REPLACEMENT_CHARS: phf::Map<&str, &str> = phf_map! { ":" => "꞉", "/" => "/", "\\" => "⧹", @@ -17,6 +17,10 @@ static REPLACEMENT_CHARS: phf::Map<&'static str, &'static str> = phf_map! { "|" => "∣" }; +// NTFS doesn't like these and pretty much shits itself if you try to do +// anything to files/folders containing em. +static UNSAFE_NTFS_ENDINGS: &[char] = &['.', ' ']; + pub fn make_string_fs_safe(s: &str) -> String { let mut str = s.to_string(); @@ -24,6 +28,10 @@ pub fn make_string_fs_safe(s: &str) -> String { str = str.replace(from, to); } + if UNSAFE_NTFS_ENDINGS.contains(&str.chars().last().unwrap()) { + str.push('_'); + } + str }