From 31649314a54e155054f45b58dc8f5e39a75d2c3d Mon Sep 17 00:00:00 2001 From: JMARyA Date: Tue, 13 Aug 2024 02:11:51 +0200 Subject: [PATCH] optimize --- src/library/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/library/mod.rs b/src/library/mod.rs index b2e1615..fb6a18c 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -239,12 +239,11 @@ impl Libary { } pub async fn clean_lost_files(&self) { - // todo : clean // tracks - for track in Track::find(doc! {}, None).await.unwrap() { - if !std::path::Path::new(&track.path).exists() { - log::info!("Cleaning lost {}", track.path); - track.delete().await.unwrap(); + for track in Track::find_partial(doc! {}, json!({"path": 1}), None).await.unwrap() { + if !std::path::Path::new(&track.path.as_ref().unwrap()).exists() { + log::info!("Cleaning lost {}", track.path.as_ref().unwrap()); + Track::remove(&track._id).await.unwrap(); } } // albums