From 8174d129fbabd2d39323678d11d868893ddb429a Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 30 Nov 2025 12:32:44 +0100 Subject: new sync cache --- tool/src/add.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'tool/src/add.rs') diff --git a/tool/src/add.rs b/tool/src/add.rs index fc43b76..40cc579 100644 --- a/tool/src/add.rs +++ b/tool/src/add.rs @@ -9,14 +9,13 @@ use jellyimport::{get_trakt, trakt::TraktKind}; use log::warn; use std::{ fmt::Display, - path::{Path, PathBuf}, -}; -use tokio::{ fs::{rename, OpenOptions}, - io::AsyncWriteExt, + io::Write, + path::{Path, PathBuf}, }; +use tokio::runtime::Handle; -pub async fn add(action: Action) -> anyhow::Result<()> { +pub fn add(action: Action, rt: &Handle) -> anyhow::Result<()> { match action { Action::Add { media } => { let theme = ColorfulTheme::default(); @@ -36,7 +35,7 @@ pub async fn add(action: Action) -> anyhow::Result<()> { let trakt = get_trakt()?; - let results = trakt.search(search_kinds, &name).await?; + let results = trakt.search(search_kinds, &name, rt)?; if results.is_empty() { warn!("no search results"); @@ -79,10 +78,8 @@ pub async fn add(action: Action) -> anyhow::Result<()> { .append(true) .write(true) .create(true) - .open(flagspath) - .await? - .write_all(flag.as_bytes()) - .await?; + .open(flagspath)? + .write_all(flag.as_bytes())?; } } else { let ext = media @@ -111,7 +108,7 @@ pub async fn add(action: Action) -> anyhow::Result<()> { .interact() .unwrap() { - rename(media, newpath).await?; + rename(media, newpath)?; } } -- cgit v1.3