From fd8d5ffe9aa2be43970e507d21cfbefba060f208 Mon Sep 17 00:00:00 2001 From: minish Date: Wed, 4 Jan 2023 22:38:52 +0000 Subject: [PATCH] Revert "added content types for cached uploads. weird caching bug still not fixed" This reverts commit c15a0c2161ab509f46c10d84d8003741a1e29b3e --- Cargo.lock | 20 -------------------- Cargo.toml | 1 - src/new.rs | 2 -- src/view.rs | 16 ++-------------- 4 files changed, 2 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6f099f..f61015f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,7 +107,6 @@ dependencies = [ "bytes", "hyper", "memory-cache-rs", - "mime_guess", "rand", "tokio", "tokio-stream", @@ -386,16 +385,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "mio" version = "0.8.5" @@ -789,15 +778,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-ident" version = "1.0.5" diff --git a/Cargo.toml b/Cargo.toml index 786327b..350ba99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,4 @@ tokio-stream = "0.1" tower = "0.4.13" bytes = "1" rand = "0.8.5" -mime_guess = "2.0.4" memory-cache-rs = "0.2.0" diff --git a/src/new.rs b/src/new.rs index da0d8c9..44f4162 100644 --- a/src/new.rs +++ b/src/new.rs @@ -139,8 +139,6 @@ pub async fn new( println!("[upl] caching upload!!"); cache.insert(name, data.freeze(), Some(Duration::from_secs(120))); } - - drop(cache); }); Ok(url) diff --git a/src/view.rs b/src/view.rs index 71fcf54..c6efb00 100644 --- a/src/view.rs +++ b/src/view.rs @@ -7,11 +7,10 @@ use std::{ use axum::{ body::StreamBody, extract::{Path, State}, - response::{IntoResponse, Response}, debug_handler, http::HeaderValue, + response::{IntoResponse, Response}, debug_handler, }; use bytes::{buf::Reader, Bytes}; use hyper::StatusCode; -use mime_guess::{mime, Mime}; use tokio::fs::File; use tokio_util::io::ReaderStream; @@ -77,18 +76,7 @@ pub async fn view( let data = cache_item.unwrap().clone(); - drop(cache); - - let contentType = mime_guess::from_path(name).first().unwrap_or(mime::APPLICATION_OCTET_STREAM).to_string(); - - let mut res = data.into_response(); - - let mut headers = res.headers_mut(); - - headers.clear(); - headers.insert("content-type", HeaderValue::from(contentType)); - - return res; + return data.into_response(); } /* pub async fn view(