From 47b72f6f04032b114a1031392f44fc1f9ff23553 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Fri, 15 Nov 2024 11:56:12 -0800 Subject: [PATCH] fix: get lock as late as possible --- src/router/upload.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/router/upload.rs b/src/router/upload.rs index 99e9354..6f96026 100644 --- a/src/router/upload.rs +++ b/src/router/upload.rs @@ -74,8 +74,8 @@ async fn upload_to_zip( .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?; } - let mut records = state.records.lock().await; let record = UploadRecord::new(archive_path); + let mut records = state.records.lock().await; records.insert(cache_name.clone(), record.clone()); let records_cache = records.clone();