aboutsummaryrefslogtreecommitdiff
path: root/import
diff options
context:
space:
mode:
Diffstat (limited to 'import')
-rw-r--r--import/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/import/src/lib.rs b/import/src/lib.rs
index 97b9950..9618d96 100644
--- a/import/src/lib.rs
+++ b/import/src/lib.rs
@@ -39,9 +39,10 @@ use std::{
ops::Deref,
path::{Path, PathBuf},
sync::{Arc, LazyLock},
+ time::Duration,
};
use tmdb::{parse_release_date, Tmdb};
-use tokio::{io::AsyncWriteExt, sync::Semaphore, task::spawn_blocking};
+use tokio::{io::AsyncWriteExt, sync::Semaphore, task::spawn_blocking, time::sleep};
use trakt::Trakt;
static IMPORT_SEM: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(1));
@@ -51,9 +52,14 @@ struct Apis {
tmdb: Option<Tmdb>,
}
+pub fn is_importing() -> bool {
+ IMPORT_SEM.available_permits() <= 0
+}
+
pub async fn import(db: &DataAcid, fed: &Federation) -> anyhow::Result<()> {
let permit = IMPORT_SEM.try_acquire()?;
+ sleep(Duration::from_secs(5)).await;
{
let txn = db.inner.begin_write()?;
let mut table = txn.open_table(T_NODE_IMPORT)?;