From 2c27dc3bf6beb2d38b25e7ae3582c58b3806e370 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Wed, 25 Sep 2024 13:11:33 +0200 Subject: [PATCH] fix: Get all necessary info before locking --- src/handlers.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handlers.rs b/src/handlers.rs index ddeb099..8bbf2fa 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -22,11 +22,11 @@ pub async fn rescan_files( base_path: String, State(state): State>>>, ) -> impl IntoResponse { + let new_files = utils::find_files(&base_path).expect("Error trying to refresh list"); + let mut files = state.write().unwrap(); // Adquire lock - files.clear(); - - files.extend(utils::find_files(&base_path).expect("Error trying to refresh list")); + files.extend(new_files); "Files rescanned successfuly" }