feat: when scanning, skip known paths
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
In the future we'll have to check for updated time, but this is a basic countermeasure to having to clear the db and rescan the whole collection.
This commit is contained in:
parent
c2d1110e4a
commit
b6e7a36511
1 changed files with 13 additions and 1 deletions
|
|
@ -2,7 +2,8 @@ use audiotags::MimeType;
|
|||
use color_eyre::{Report, Result};
|
||||
use entities::{
|
||||
cover_art, genre, music_folder,
|
||||
prelude::{CoverArt, Genre, MusicFolder},
|
||||
prelude::{CoverArt, Genre, MusicFolder, Track},
|
||||
track,
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use once_cell::sync::Lazy;
|
||||
|
|
@ -132,6 +133,17 @@ async fn handle_entry(
|
|||
state: Arc<RwLock<ScanState>>,
|
||||
) -> Result<()> {
|
||||
let path = entry.path();
|
||||
|
||||
{
|
||||
let query = Track::find().filter(track::Column::Path.eq(path.to_string_lossy()));
|
||||
let res = query.one(tx).await;
|
||||
|
||||
if let Ok(Some(_)) = res {
|
||||
debug!("Skipping already scanned file {path:?}");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let file_type = entry.file_type().await?;
|
||||
|
||||
if !file_type.is_file() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue