From baa820c60675f84ed0652f0b11feefe9230a97a1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Apr 2021 20:28:09 +0200 Subject: Remove helper Source::exists() It is easier for the caller (because more visible what happens) to call `Source::path().exists()`. Signed-off-by: Matthias Beyer --- src/commands/source.rs | 8 ++++---- src/source/mod.rs | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/source.rs b/src/commands/source.rs index 7f4a1bb..50f6a30 100644 --- a/src/commands/source.rs +++ b/src/commands/source.rs @@ -154,7 +154,7 @@ pub async fn list_missing(_: &ArgMatches, config: &Configuration, repo: Reposito repo.packages().try_for_each(|p| { for source in sc.sources_for(p) { - if !source.exists() { + if !source.path().exists() { writeln!( outlock, "{} {} -> {}", @@ -244,7 +244,7 @@ pub async fn download( let bar = multi.add(progressbars.spinner()); bar.set_message(&format!("Downloading {}", source.url())); async move { - if !source.exists() && source.download_manually() { + if !source.path().exists() && source.download_manually() { return Err(anyhow!( "Cannot download source that is marked for manual download" )) @@ -253,10 +253,10 @@ pub async fn download( .map_err(Error::from); } - if source.exists() && !force { + if source.path().exists() && !force { Err(anyhow!("Source exists: {}", source.path().display())) } else { - if source.exists() { + if source.path().exists() { let _ = source.remove_file().await?; } diff --git a/src/source/mod.rs b/src/source/mod.rs index ec0e2e2..7ce00e5 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -75,10 +75,6 @@ impl SourceEntry { .collect() } - pub fn exists(&self) -> bool { - self.source_file_path().exists() - } - pub fn path(&self) -> PathBuf { self.source_file_path() } -- cgit v1.2.3