diff --git a/Cargo.lock b/Cargo.lock index 1d5b527..d94c4fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,6 +41,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + [[package]] name = "argh" version = "0.1.13" @@ -61,7 +67,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -81,7 +87,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -245,28 +251,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "fnv" version = "1.0.7" @@ -338,7 +322,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -875,7 +859,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -958,17 +942,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.104" @@ -986,18 +959,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -1035,7 +996,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -1094,11 +1055,11 @@ checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" name = "torn" version = "0.2.0" dependencies = [ + "anyhow", "argh", "axum", "chrono", "config", - "failure", "futures", "heck", "humantime-serde", @@ -1223,12 +1184,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "uuid" version = "1.17.0" @@ -1277,7 +1232,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.104", + "syn", "wasm-bindgen-shared", ] @@ -1299,7 +1254,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1343,7 +1298,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -1354,7 +1309,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5667f61..c0094cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ license = "MIT" argh = "0.1" config = { version = "0.15", default-features = false, features = ["toml"] } pretty_env_logger = "0.5" -failure = "0.1" +anyhow = "1.0" futures = "0.3" heck = "0.5" humantime-serde = "1.1" diff --git a/src/handbrake.rs b/src/handbrake.rs index 96ae551..60b0c3a 100644 --- a/src/handbrake.rs +++ b/src/handbrake.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::Arc; -use failure::{Error, format_err}; +use anyhow::{Result, anyhow}; use log::info; use tokio::{ fs, @@ -39,7 +39,7 @@ struct Job { } impl HandbrakeProcess { - pub fn new(config: Handbrake) -> (HandbrakeProcess, JoinHandle>) { + pub fn new(config: Handbrake) -> (HandbrakeProcess, JoinHandle>) { let (tx, mut rx) = unbounded_channel(); let jobs = Arc::new(RwLock::new(HashMap::::new())); let jobs_clone = jobs.clone(); @@ -85,7 +85,7 @@ impl HandbrakeProcess { (HandbrakeProcess { tx, jobs }, handle) } - pub async fn queue(&self, src: PathBuf, dest: PathBuf) -> Result<(), Error> { + pub async fn queue(&self, src: PathBuf, dest: PathBuf) -> Result<()> { let job_id = format!("{}", uuid::Uuid::new_v4()); let job_status = JobStatus { id: job_id.clone(), @@ -137,7 +137,7 @@ async fn handbrake( dest: &Path, job_id: &str, jobs: &Arc>>, -) -> Result<(), Error> { +) -> Result<()> { let disc_meta: DiscMetadata = toml::from_slice(&fs::read(src.join("meta.toml")).await?)?; let args = match disc_meta.disc_type { @@ -165,16 +165,16 @@ async fn handbrake( let source_file = path .to_str() - .ok_or_else(|| format_err!("path is not a valid string: {:?}", path))?; + .ok_or_else(|| anyhow!("path is not a valid string: {:?}", path))?; let dest_file = dest.join( output_file .file_name() - .ok_or_else(|| format_err!("path is not a valid string: {:?}", dest))?, + .ok_or_else(|| anyhow!("path is not a valid string: {:?}", dest))?, ); let dest_file = dest_file .to_str() - .ok_or_else(|| format_err!("path is not a valid string: {:?}", dest_file))?; + .ok_or_else(|| anyhow!("path is not a valid string: {:?}", dest_file))?; // Update progress to indicate file processing started { @@ -204,7 +204,7 @@ async fn handbrake( let status = child.wait().await?; if !status.success() { - return Err(format_err!( + return Err(anyhow!( "error code {:?} from handbrake, stopping process", status.code() )); diff --git a/src/main.rs b/src/main.rs index d3c39af..59d2590 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{env, path::Path}; use argh::FromArgs; -use failure::Error; +use anyhow::Result; use futures::future::try_join_all; use log::{error, info, warn}; use tokio::time::sleep; @@ -18,7 +18,7 @@ mod makemkv; mod web; #[tokio::main] -async fn main() -> Result<(), Error> { +async fn main() -> Result<()> { if env::var_os("RUST_LOG").is_none() { // nothing else should be running right now // so this is as safe as it can be for now @@ -51,7 +51,7 @@ async fn main() -> Result<(), Error> { Ok(()) } -async fn rip(settings: Settings) -> Result<(), Error> { +async fn rip(settings: Settings) -> Result<()> { let (hb_process, hb_handle) = HandbrakeProcess::new(settings.handbrake.clone()); process_existing_directories(&hb_process, &settings).await?; @@ -99,7 +99,7 @@ fn spawn_rip_process( device: String, settings: Settings, hb_process: HandbrakeProcess, -) -> JoinHandle> { +) -> JoinHandle> { tokio::spawn(async move { loop { let device = device.to_owned(); @@ -139,7 +139,7 @@ fn spawn_rip_process( async fn process_existing_directories( hb_process: &HandbrakeProcess, settings: &Settings, -) -> Result<(), Error> { +) -> Result<()> { if settings.makemkv.enqueue_existing_jobs { if !Path::new(&settings.directory.raw).exists() { return Ok(()); diff --git a/src/makemkv.rs b/src/makemkv.rs index 619ef75..da0f387 100644 --- a/src/makemkv.rs +++ b/src/makemkv.rs @@ -3,13 +3,13 @@ use std::{ time::SystemTime, }; -use failure::{format_err, Error}; +use anyhow::{anyhow, Result}; use tokio::{fs, process::Command}; use crate::config::MakeMKV; use crate::disc::{Disc, DiscMetadata}; -pub async fn rip(config: &MakeMKV, disc: &Disc, target_folder: &Path) -> Result { +pub async fn rip(config: &MakeMKV, disc: &Disc, target_folder: &Path) -> Result { let target_folder = { let timestamp = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH)? @@ -40,8 +40,8 @@ pub async fn rip(config: &MakeMKV, disc: &Disc, target_folder: &Path) -> Result< let status = child.wait().await?; if !status.success() { - return Err(format_err!( - "error code {:?} from handbrake, stopping process", + return Err(anyhow!( + "error code {:?} from makemkv, stopping process", status.code() )); } diff --git a/src/web.rs b/src/web.rs index 3ebc630..6a7097c 100644 --- a/src/web.rs +++ b/src/web.rs @@ -52,7 +52,7 @@ pub struct AppState { pub async fn run_web_server( settings: Settings, handbrake_process: HandbrakeProcess, -) -> Result<(), failure::Error> { +) -> Result<(), anyhow::Error> { let system_status = Arc::new(RwLock::new(SystemStatus { drives: Vec::new(), handbrake_jobs: Vec::new(), @@ -76,7 +76,7 @@ pub async fn run_web_server( info!("Web interface already running on {}", addr); return Ok(()); } - return Err(failure::format_err!( + return Err(anyhow::anyhow!( "Failed to bind to address {}: {}", addr, e @@ -92,7 +92,7 @@ pub async fn run_web_server( let listener = tokio::net::TcpListener::bind(&addr) .await - .map_err(|e| failure::format_err!("Failed to bind to address {}: {}", addr, e))?; + .map_err(|e| anyhow::anyhow!("Failed to bind to address {}: {}", addr, e))?; info!("Web interface available at http://{}", addr);