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,
|
||||
State(state): State<Arc<RwLock<Vec<utils::FileEntry>>>>,
|
||||
) -> 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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue