Compare commits
No commits in common. "12b0feba96798ad332ea23e49de671c958021dea" and "489c6ea8bf0755862db629f6033b0d89b890b264" have entirely different histories.
12b0feba96
...
489c6ea8bf
1 changed files with 10 additions and 16 deletions
|
@ -4,7 +4,7 @@ use askama::Template;
|
|||
use async_zip::{base::write::ZipFileWriter, Compression, ZipEntryBuilder};
|
||||
use axum::{
|
||||
extract::{DefaultBodyLimit, Multipart, State},
|
||||
response::{IntoResponse, Response},
|
||||
http::Response,
|
||||
routing::post,
|
||||
Router,
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ pub fn get_upload_router() -> Router<AppState> {
|
|||
async fn upload_to_zip(
|
||||
State(state): State<AppState>,
|
||||
mut body: Multipart,
|
||||
) -> Result<Response, (StatusCode, String)> {
|
||||
) -> Result<Response<String>, (StatusCode, String)> {
|
||||
tracing::debug!("{:?}", *state.records.lock().await);
|
||||
|
||||
let cache_name = util::get_random_name(10);
|
||||
|
@ -78,25 +78,19 @@ async fn upload_to_zip(
|
|||
let record = UploadRecord::new(archive_path);
|
||||
records.insert(cache_name.clone(), record.clone());
|
||||
|
||||
let records_cache = records.clone();
|
||||
// Manually drop the records mutex guard
|
||||
drop(records);
|
||||
|
||||
cache::write_to_cache(&records_cache)
|
||||
cache::write_to_cache(&records)
|
||||
.await
|
||||
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?;
|
||||
|
||||
writer.close().await.unwrap();
|
||||
|
||||
let id = cache_name;
|
||||
let impl_response = (
|
||||
StatusCode::OK,
|
||||
[
|
||||
("Content-Type", "text/html"),
|
||||
("HX-Push-Url", &format!("/link/{}", &id)),
|
||||
],
|
||||
DownloadLinkFragment { id, record },
|
||||
);
|
||||
let response = Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "text/html")
|
||||
.header("HX-Push-Url", format!("/link/{}", &id))
|
||||
.body(DownloadLinkFragment { id, record }.render().unwrap())
|
||||
.unwrap();
|
||||
|
||||
Ok(impl_response.into_response())
|
||||
Ok(response)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue