Skip to content

Commit

Permalink
refactor: remove unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jun 5, 2023
1 parent 93d1b64 commit 5485589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/console/commands/import_tracker_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,14 @@ 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 {
#[display(fmt = "internal server error")]
WrongNumberOfArgumentsError,
}

fn parse_args() -> Result<Arguments, ImportError> {
fn parse_args() -> Result<(), ImportError> {
let args: Vec<String> = env::args().skip(1).collect();

if args.len() != NUMBER_OF_ARGUMENTS {
Expand All @@ -59,7 +56,7 @@ fn parse_args() -> Result<Arguments, ImportError> {
return Err(ImportError::WrongNumberOfArgumentsError);
}

Ok(Arguments {})
Ok(())
}

fn print_usage() {
Expand All @@ -74,15 +71,16 @@ 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
///
/// # 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;
Expand Down Expand Up @@ -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");
}
3 changes: 2 additions & 1 deletion src/tracker/statistics_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 5485589

Please sign in to comment.