From 548558904930d56ec0238b5978e26b690ec55b50 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Mon, 5 Jun 2023 17:36:04 +0100 Subject: [PATCH] refactor: remove unneeded code --- src/console/commands/import_tracker_statistics.rs | 14 ++++++-------- src/tracker/statistics_importer.rs | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/console/commands/import_tracker_statistics.rs b/src/console/commands/import_tracker_statistics.rs index de6825af..2040ca95 100644 --- a/src/console/commands/import_tracker_statistics.rs +++ b/src/console/commands/import_tracker_statistics.rs @@ -35,9 +35,6 @@ use crate::tracker::statistics_importer::StatisticsImporter; const NUMBER_OF_ARGUMENTS: usize = 0; -#[derive(Debug)] -pub struct Arguments {} - #[derive(Debug, Display, PartialEq, Error)] #[allow(dead_code)] pub enum ImportError { @@ -45,7 +42,7 @@ pub enum ImportError { WrongNumberOfArgumentsError, } -fn parse_args() -> Result { +fn parse_args() -> Result<(), ImportError> { let args: Vec = env::args().skip(1).collect(); if args.len() != NUMBER_OF_ARGUMENTS { @@ -59,7 +56,7 @@ fn parse_args() -> Result { return Err(ImportError::WrongNumberOfArgumentsError); } - Ok(Arguments {}) + Ok(()) } fn print_usage() { @@ -74,7 +71,8 @@ fn print_usage() { } pub async fn run_importer() { - import(&parse_args().expect("unable to parse command arguments")).await; + parse_args().expect("unable to parse command arguments"); + import().await; } /// Import Command Arguments @@ -82,7 +80,7 @@ pub async fn run_importer() { /// # Panics /// /// Panics if `Configuration::load_from_file` has any error. -pub async fn import(_args: &Arguments) { +pub async fn import() { println!("Importing statistics from linked tracker ..."); let configuration = init_configuration().await; @@ -110,5 +108,5 @@ pub async fn import(_args: &Arguments) { tracker_statistics_importer .import_all_torrents_statistics() .await - .expect("variable `tracker_service` is unable to `update_torrents`"); + .expect("should import all torrents statistics"); } diff --git a/src/tracker/statistics_importer.rs b/src/tracker/statistics_importer.rs index c5044c5c..f2ae0dce 100644 --- a/src/tracker/statistics_importer.rs +++ b/src/tracker/statistics_importer.rs @@ -50,10 +50,11 @@ impl StatisticsImporter { // ``` if let Some(err) = ret.err() { - error!( + let message = format!( "Error updating torrent tracker stats for torrent with id {}: {:?}", torrent.torrent_id, err ); + error!("{}", message); } }