about summary refs log tree commit diff
path: root/src/media/storage/file.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2025-01-01 05:42:45 +0300
committerVika <vika@fireburn.ru>2025-01-01 07:08:33 +0300
commit5ad8443c8d6d9ed3f9d28ac52af529ceb41d741f (patch)
tree5d6dd326abd9cd135652e68fc893c2a95486a798 /src/media/storage/file.rs
parentdf509eadc9aecef605194b7c97c5fb02bf928b79 (diff)
downloadkittybox-5ad8443c8d6d9ed3f9d28ac52af529ceb41d741f.tar.zst
Get rid of base64 and hex in favor of data_encoding crate
Less dependency duplication = more fun

Change-Id: Icbd0497a68fdd5bea3757e3c62c80008b87bce96
Diffstat (limited to 'src/media/storage/file.rs')
-rw-r--r--src/media/storage/file.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/media/storage/file.rs b/src/media/storage/file.rs
index 711b298..e432945 100644
--- a/src/media/storage/file.rs
+++ b/src/media/storage/file.rs
@@ -99,15 +99,15 @@ impl MediaStore for FileStore {
         tempfile.flush().await?;
         tempfile.into_inner().sync_all().await?;
 
-        let hash = hasher.finalize();
-        debug!("Pending upload hash: {}", hex::encode(hash));
+        let hash = data_encoding::HEXLOWER.encode(&hasher.finalize());
+        debug!("Pending upload hash: {}", hash);
         let filename = format!(
             "{}/{}/{}/{}/{}",
-            hex::encode([hash[0]]),
-            hex::encode([hash[1]]),
-            hex::encode([hash[2]]),
-            hex::encode([hash[3]]),
-            hex::encode(&hash[4..32])
+            &hash[0..2],
+            &hash[2..4],
+            &hash[4..6],
+            &hash[6..8],
+            &hash[8..]
         );
         let domain_str = domain.to_string();
         let filepath = self.base.join(domain_str.as_str()).join(&filename);
@@ -115,7 +115,7 @@ impl MediaStore for FileStore {
         let metapath = self.base.join(domain_str.as_str()).join(&metafilename);
         let metatemppath = self.base.join(domain_str.as_str()).join(metafilename + ".tmp");
         metadata.length = std::num::NonZeroUsize::new(length);
-        metadata.etag = Some(hex::encode(hash));
+        metadata.etag = Some(hash);
         debug!("File path: {}, metadata: {}", filepath.display(), metapath.display());
         {
             let parent = filepath.parent().unwrap();