From 09f3143189fe71cfda2f3072c6fba5a494aed1aa Mon Sep 17 00:00:00 2001 From: euzu Date: Mon, 4 Nov 2024 16:13:46 +0100 Subject: [PATCH] removed crate uuid --- Cargo.lock | 30 ------------------------------ Cargo.toml | 1 - src/api/api_model.rs | 3 ++- src/repository/storage.rs | 13 ++++++++++++- 4 files changed, 14 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4114d08c8..0f149a802 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1469,7 +1469,6 @@ dependencies = [ "time", "unidecode", "url", - "uuid", ] [[package]] @@ -2288,12 +2287,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sha1_smol" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" - [[package]] name = "sha2" version = "0.10.8" @@ -2685,29 +2678,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" -dependencies = [ - "getrandom", - "rand", - "sha1_smol", - "uuid-macro-internal", -] - -[[package]] -name = "uuid-macro-internal" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b91f57fe13a38d0ce9e28a03463d8d3c2468ed03d75375110ec71d93b449a08" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "v_htmlescape" version = "0.15.8" diff --git a/Cargo.toml b/Cargo.toml index 599149c46..625df11bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,6 @@ log = "0.4" env_logger = "0.11" rustelebot = "0.3" bincode = "1.3" -uuid = { version = "1", features = ["v4", "v5", "fast-rng", "macro-diagnostics"] } rand = "0.8" rpassword = "7.3" flate2 = "1" diff --git a/src/api/api_model.rs b/src/api/api_model.rs index df39c07a6..0cd4758e1 100644 --- a/src/api/api_model.rs +++ b/src/api/api_model.rs @@ -11,6 +11,7 @@ use unidecode::unidecode; use crate::model::api_proxy::{ApiProxyConfig, ApiProxyServerInfo, ProxyUserCredentials}; use crate::model::config::{Config, ConfigApi, ConfigRename, ConfigSort, ConfigTargetOptions, InputType, MessagingConfig, ProcessTargets, TargetOutput, VideoConfig, VideoDownloadConfig}; use crate::model::config::ProcessingOrder; +use crate::repository::storage::{hash_string_as_hex}; /// File-Download information. #[derive(Clone)] @@ -100,7 +101,7 @@ impl FileDownload { file_path.to_str()?; Some(FileDownload { - uuid: uuid::Uuid::new_v4().to_string(), + uuid: hash_string_as_hex(req_url), file_dir, file_path, filename, diff --git a/src/repository/storage.rs b/src/repository/storage.rs index 723f0e94b..9ec25703d 100644 --- a/src/repository/storage.rs +++ b/src/repository/storage.rs @@ -1,5 +1,5 @@ use std::path::{Path, PathBuf}; - +use std::fmt::Write; use crate::m3u_filter_error::{M3uFilterError, M3uFilterErrorKind}; use crate::model::config::{Config, ConfigInput}; use crate::utils::file_utils; @@ -14,6 +14,17 @@ pub(crate) fn hash_string(url: &str) -> [u8; 32] { hash.into() // convert to hash array } +fn hex_encode(bytes: &[u8]) -> String { + bytes.iter().fold(String::new(), |mut output, b| { + let _ = write!(output, "{b:02X}"); + output + }) +} + +pub(crate) fn hash_string_as_hex(url: &str) -> String { + hex_encode(&hash_string(url)) +} + pub(in crate::repository) fn get_target_id_mapping_file(target_path: &Path) -> PathBuf { target_path.join(PathBuf::from(FILE_ID_MAPPING)) }