Compare commits
2 Commits
93a41cfcbb
...
2676515b4e
| Author | SHA1 | Date | |
|---|---|---|---|
| 2676515b4e | |||
|
c498e1a7fa
|
@@ -5,7 +5,7 @@ use crate::prelude::*;
|
||||
use image_convert::ImageResource;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub async fn full_scan(state: &BackendState) {
|
||||
pub fn full_scan(state: &BackendState) {
|
||||
info!("Ingest running...");
|
||||
|
||||
let ingest_path = state.config.audio_path.clone();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::ingest::scan::full_scan;
|
||||
use crate::prelude::*;
|
||||
|
||||
use tokio::task::{JoinHandle, spawn};
|
||||
use tokio::task::{JoinHandle, spawn, spawn_blocking};
|
||||
use tokio::time::{Duration, Instant, interval_at};
|
||||
|
||||
pub const INITIAL_SCAN_DELAY: Duration = Duration::from_secs(10);
|
||||
@@ -10,7 +10,7 @@ pub const SCAN_INTERVAL: Duration = Duration::from_hours(1);
|
||||
/// Start the ingest task
|
||||
/// Waits an initial delay for startup to complete, then runs a full ingest
|
||||
/// scan on a regular interval
|
||||
pub async fn start_task(state: BackendState) -> JoinHandle<!> {
|
||||
pub fn start_task(state: BackendState) -> JoinHandle<!> {
|
||||
info!("Starting ingest task...");
|
||||
|
||||
let start_time = Instant::now() + INITIAL_SCAN_DELAY;
|
||||
@@ -19,7 +19,16 @@ pub async fn start_task(state: BackendState) -> JoinHandle<!> {
|
||||
spawn(async move {
|
||||
loop {
|
||||
scan_interval.tick().await;
|
||||
full_scan(&state).await;
|
||||
|
||||
let state = state.clone();
|
||||
|
||||
let scan_handle = spawn_blocking(move || {
|
||||
full_scan(&state);
|
||||
});
|
||||
|
||||
if let Err(e) = scan_handle.await {
|
||||
error!("Ingest scan panicked: {e}");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user