fix: dont store cache in current dir with --report option

This commit is contained in:
ThetaDev 2024-08-18 00:51:41 +02:00
parent 3599acafef
commit 6009de7bdd
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6

View file

@ -19,6 +19,7 @@ use rustypipe::{
Verification, YouTubeItem, Verification, YouTubeItem,
}, },
param::{search_filter, ChannelVideoTab, Country, Language, StreamFilter}, param::{search_filter, ChannelVideoTab, Country, Language, StreamFilter},
report::FileReporter,
}; };
use rustypipe_downloader::{ use rustypipe_downloader::{
DownloadError, DownloadQuery, DownloadVideo, Downloader, DownloaderBuilder, DownloadError, DownloadQuery, DownloadVideo, Downloader, DownloaderBuilder,
@ -535,16 +536,18 @@ async fn run() -> anyhow::Result<()> {
.with_writer(ProgWriter(multi.clone())) .with_writer(ProgWriter(multi.clone()))
.init(); .init();
let mut storage_dir = dirs::data_dir().expect("no data dir");
storage_dir.push("rustypipe");
std::fs::create_dir_all(&storage_dir).expect("could not create data dir");
let mut rp = RustyPipe::builder() let mut rp = RustyPipe::builder()
.storage_dir(storage_dir)
.visitor_data_opt(cli.vdata) .visitor_data_opt(cli.vdata)
.timeout(Duration::from_secs(15)); .timeout(Duration::from_secs(15));
if cli.report { if cli.report {
rp = rp.report(); rp = rp
} else { .report()
let mut storage_dir = dirs::data_dir().expect("no data dir"); .reporter(Box::new(FileReporter::new("rustypipe_reports")));
storage_dir.push("rustypipe");
std::fs::create_dir_all(&storage_dir).expect("could not create data dir");
rp = rp.storage_dir(storage_dir);
} }
if let Some(lang) = cli.lang { if let Some(lang) = cli.lang {
rp = rp.lang(Language::from_str(&lang.to_ascii_lowercase()).expect("invalid language")); rp = rp.lang(Language::from_str(&lang.to_ascii_lowercase()).expect("invalid language"));