diff options
Diffstat (limited to 'tool/src/add.rs')
| -rw-r--r-- | tool/src/add.rs | 19 |
1 files changed, 8 insertions, 11 deletions
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)?; } } |