From ec050b19a5a9fc19c8480093b96a704352fcba61 Mon Sep 17 00:00:00 2001 From: minish Date: Sun, 20 Oct 2024 01:42:24 -0400 Subject: [PATCH] fix empty file extensions (0.2.6) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/engine.rs | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c59ca12..40b57ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,7 +228,7 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "breeze" -version = "0.2.5" +version = "0.2.6" dependencies = [ "anyhow", "argh", diff --git a/Cargo.toml b/Cargo.toml index 8d0389f..21db189 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "breeze" -version = "0.2.5" +version = "0.2.6" edition = "2021" [dependencies] diff --git a/src/engine.rs b/src/engine.rs index ddd02de..55dccb6 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -148,10 +148,13 @@ impl Engine { #[async_recursion::async_recursion] pub async fn gen_saved_name(&self, ext: &str) -> String { // generate a 6-character alphanumeric string - let id: String = Alphanumeric.sample_string(&mut rand::thread_rng(), 6); + let mut saved_name: String = Alphanumeric.sample_string(&mut rand::thread_rng(), 6); - // path on disk - let saved_name = format!("{}.{}", id, ext); + // if we have an extension, add it now + if !ext.is_empty() { + saved_name.push('.'); + saved_name.push_str(ext); + } if !self.has(&saved_name).await { saved_name