fix: Get all necessary info before locking

This commit is contained in:
Dendy 2024-09-25 13:11:33 +02:00
parent 0fa5fd4d04
commit 2c27dc3bf6
1 changed files with 3 additions and 3 deletions

View File

@ -22,11 +22,11 @@ pub async fn rescan_files(
base_path: String, base_path: String,
State(state): State<Arc<RwLock<Vec<utils::FileEntry>>>>, State(state): State<Arc<RwLock<Vec<utils::FileEntry>>>>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let new_files = utils::find_files(&base_path).expect("Error trying to refresh list");
let mut files = state.write().unwrap(); // Adquire lock let mut files = state.write().unwrap(); // Adquire lock
files.clear(); files.clear();
files.extend(new_files);
files.extend(utils::find_files(&base_path).expect("Error trying to refresh list"));
"Files rescanned successfuly" "Files rescanned successfuly"
} }