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" }