fix: Get all necessary info before locking
This commit is contained in:
parent
0fa5fd4d04
commit
2c27dc3bf6
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue