1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-05-30 08:36:47 +02:00

Clean up some clanker-written code

Signed-off-by: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com>
This commit is contained in:
TheGeneralist 2026-04-02 18:54:58 +02:00
parent 26d94a8289
commit 741e33c3af
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
2 changed files with 6 additions and 10 deletions

View file

@ -7,7 +7,7 @@ use std::{
fs, fs,
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Command, process::Command,
sync::{Mutex, OnceLock}, sync::OnceLock,
}; };
use super::local; use super::local;
@ -281,7 +281,7 @@ fn archive_asset_reference(
mod tests { mod tests {
use super::*; use super::*;
use std::{ use std::{
sync::MutexGuard, sync::{Mutex, MutexGuard},
time::{SystemTime, UNIX_EPOCH}, time::{SystemTime, UNIX_EPOCH},
}; };

View file

@ -356,7 +356,6 @@ fn main() -> Result<()> {
}; };
let source = determine_source(path); let source = determine_source(path);
let resolved_path = resolve_source_path(path, &source);
match source { match source {
Source::Other => { Source::Other => {
@ -394,6 +393,7 @@ fn main() -> Result<()> {
} }
// Other sources // Other sources
let path = resolve_source_path(path, &source);
let hash = match source { let hash = match source {
Source::YouTubeVideo Source::YouTubeVideo
| Source::X | Source::X
@ -402,11 +402,7 @@ fn main() -> Result<()> {
| Source::TikTok | Source::TikTok
| Source::Reddit | Source::Reddit
| Source::Snapchat => { | Source::Snapchat => {
match downloader::ytdlp::download( match downloader::ytdlp::download(path.clone(), &store_path, &timestamp) {
resolved_path.clone(),
&store_path,
&timestamp,
) {
Ok(h) => h, Ok(h) => h,
Err(e) => { Err(e) => {
eprintln!("Failed to download from YouTube: {e}"); eprintln!("Failed to download from YouTube: {e}");
@ -415,7 +411,7 @@ fn main() -> Result<()> {
} }
} }
Source::Local => { Source::Local => {
match downloader::local::save(resolved_path.clone(), &store_path, &timestamp) { match downloader::local::save(path.clone(), &store_path, &timestamp) {
Ok(h) => h, Ok(h) => h,
Err(e) => { Err(e) => {
eprintln!("Failed to archive local file: {e}"); eprintln!("Failed to archive local file: {e}");
@ -435,7 +431,7 @@ fn main() -> Result<()> {
| Source::Reddit | Source::Reddit
| Source::Snapchat => ".mp4", | Source::Snapchat => ".mp4",
Source::Local => { Source::Local => {
let p = Path::new(resolved_path.trim_start_matches("file://")); let p = Path::new(path.trim_start_matches("file://"));
&p.extension() &p.extension()
.map_or(String::new(), |ext| format!(".{}", ext.to_string_lossy())) .map_or(String::new(), |ext| format!(".{}", ext.to_string_lossy()))
} }