chore: remove tracing and replace color-eyre with anyhow

This commit is contained in:
uku 2025-05-21 22:40:24 +02:00
parent 6f46c768ce
commit c39c46d419
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
6 changed files with 20 additions and 230 deletions

202
Cargo.lock generated
View file

@ -18,13 +18,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "aho-corasick"
version = "1.1.3"
name = "anyhow"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]]
name = "arboard"
@ -217,33 +214,6 @@ dependencies = [
"error-code",
]
[[package]]
name = "color-eyre"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e1761c0e16f8883bbbb8ce5990867f4f06bf11a0253da6495a04ce4b6ef0ec"
dependencies = [
"backtrace",
"color-spantrace",
"eyre",
"indenter",
"once_cell",
"owo-colors",
"tracing-error",
]
[[package]]
name = "color-spantrace"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ddd8d5bfda1e11a501d0a7303f3bfed9aa632ebdb859be40d0fd70478ed70d5"
dependencies = [
"once_cell",
"owo-colors",
"tracing-core",
"tracing-error",
]
[[package]]
name = "concurrent-queue"
version = "2.5.0"
@ -392,16 +362,6 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "eyre"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
dependencies = [
"indenter",
"once_cell",
]
[[package]]
name = "fastrand"
version = "2.3.0"
@ -1086,12 +1046,6 @@ dependencies = [
"icu_properties",
]
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "2.9.0"
@ -1124,12 +1078,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libadwaita"
version = "0.7.2"
@ -1217,15 +1165,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "memchr"
version = "2.7.4"
@ -1299,16 +1238,6 @@ dependencies = [
"memoffset",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "objc2"
version = "0.6.1"
@ -1414,18 +1343,6 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owo-colors"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564"
[[package]]
name = "pango"
version = "0.20.9"
@ -1670,50 +1587,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "relm4"
version = "0.9.1"
@ -2014,15 +1887,6 @@ dependencies = [
"serde",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "1.3.0"
@ -2173,16 +2037,6 @@ dependencies = [
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [
"cfg-if",
"once_cell",
]
[[package]]
name = "tinystr"
version = "0.8.1"
@ -2345,46 +2199,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-error"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
dependencies = [
"tracing",
"tracing-subscriber",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
@ -2397,8 +2211,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
name = "tyrolienne"
version = "0.1.0"
dependencies = [
"anyhow",
"arboard",
"color-eyre",
"dirs",
"futures",
"relm4",
@ -2409,8 +2223,6 @@ dependencies = [
"tokio",
"tokio-util",
"toml",
"tracing",
"tracing-subscriber",
"urlencoding",
]
@ -2467,12 +2279,6 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "valuable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "version-compare"
version = "0.2.0"

View file

@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2024"
[dependencies]
anyhow = "1.0.98"
arboard = { version = "3.5.0", default-features = false }
color-eyre = "0.6.4"
dirs = "6.0.0"
futures = "0.3.31"
relm4 = { version = "0.9.1", features = ["gnome_47", "libadwaita"] }
@ -16,8 +16,6 @@ serde_json = "1.0.140"
tokio = { version = "1.45.0", features = ["fs", "io-util", "process"] }
tokio-util = { version = "0.7.15", features = ["io"] }
toml = "0.8.22"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
urlencoding = "2.1.3"
[profile.release]

View file

@ -3,7 +3,7 @@ use std::{
process::Stdio,
};
use color_eyre::eyre::{ContextCompat, Result, bail};
use anyhow::{Context, Result, bail};
use futures::channel::oneshot;
use relm4::Sender;
use tokio::{
@ -58,8 +58,13 @@ impl From<String> for Codec {
}
pub fn check() -> Result<()> {
std::process::Command::new("ffmpeg").output()?;
std::process::Command::new("ffprobe").output()?;
std::process::Command::new("ffmpeg")
.output()
.context("could not find ffmpeg")?;
std::process::Command::new("ffprobe")
.output()
.context("could not find ffprobe")?;
Ok(())
}
@ -89,7 +94,7 @@ pub async fn get_video_meta(path: &Path) -> Result<VideoMeta> {
StreamInfo::Video { width, height } => Some((*width, *height)),
_ => None,
})
.wrap_err("could not get stream information from ffprobe")?;
.context("could not get stream information from ffprobe")?;
let audio_streams = output
.streams
@ -162,7 +167,7 @@ pub async fn convert_video(
if line.starts_with("out_time_us") {
let (_, current_duration) = line
.split_once("=")
.wrap_err_with(|| format!("could not parse ffmpeg output: {line}"))?;
.with_context(|| format!("could not parse ffmpeg output: {line}"))?;
if current_duration != "N/A" {
sender.emit(ProgressMessage::AbsProgress(

View file

@ -5,7 +5,7 @@ mod zipline;
use std::{borrow::Cow, path::PathBuf, time::Duration};
use color_eyre::eyre::{OptionExt, Result, bail};
use anyhow::{Context, Result, bail};
use gobject::GtkZiplineFolder;
use relm::{Dialog, DialogInput, StandaloneDialog, Toast, ToastInput};
use relm4::{
@ -16,8 +16,6 @@ use relm4::{
prelude::{AsyncComponent, AsyncComponentParts},
tokio,
};
use tracing::Level;
use tracing_subscriber::EnvFilter;
use urlencoding::Encoded;
use zipline::ZiplineFolder;
@ -392,19 +390,11 @@ impl AsyncComponent for Tyrolienne {
}
// TODO app icon
fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env().add_directive(Level::INFO.into()))
.init();
color_eyre::install()?;
fn main() {
match ffmpeg::check().and_then(|_| get_config()) {
Ok(config) => RelmApp::new("net.uku3lig.Tyrolienne").run_async::<Tyrolienne>(config),
Err(e) => RelmApp::new("net.uku3lig.Tyrolienne").run::<StandaloneDialog>(e.to_string()),
}
Ok(())
}
fn get_config() -> Result<Config> {
@ -456,28 +446,20 @@ async fn the_process(app: UploadInfo, sender: &Sender<ProgressMessage>) -> Resul
.await?;
sender.emit(ProgressMessage::SetStep(Step::Uploading));
if let Some(folder) = app.folder.as_ref() {
tracing::info!("uploading to folder '{}'...", folder.name);
} else {
tracing::info!("uploading video...");
}
let res = zipline::upload_file(&app.config, sender, app.folder.as_ref(), &out_path).await?;
let zp_file = &res.files[0];
sender.emit(ProgressMessage::SetStep(Step::Thumbnail));
tracing::info!("recalculating thumbnails...");
zipline::recalc_thumbnails(&app.config).await?;
tokio::time::sleep(Duration::from_secs(2)).await;
tracing::info!("fetching thumbnail url...");
let res = zipline::get_file_details(&app.config, &zp_file.id).await?;
let thumbnail_url = res
.thumbnail_url(&app.config)
.ok_or_eyre("could not get thumbnail url")?;
.context("could not get thumbnail url")?;
sender.emit(ProgressMessage::SetStep(Step::Shortening));

View file

@ -132,8 +132,7 @@ impl SimpleComponent for Toast {
self.visible = true;
if let Err(e) = Clipboard::new().and_then(|mut c| c.set_text(text)) {
tracing::error!("could not copy url to clipboard: {e}");
self.text = "Could not copy".into();
self.text = e.to_string();
} else {
self.text = "Copied url to clipboard".into();
}

View file

@ -1,6 +1,6 @@
use std::{path::Path, sync::LazyLock};
use color_eyre::eyre::{Result, bail};
use anyhow::{Result, bail};
use futures::StreamExt;
use relm4::Sender;
use reqwest::{