Skip to content

Commit

Permalink
Added a '-f' option for force downloading even when the versions match.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedegaard committed Apr 13, 2020
1 parent 44508be commit 46c8de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ colored = "^1.6.1"
term-painter = "^0.2.4"
chrono = "^0.4.6"
dirs = "^2.0.2"
number_prefix = "0.4"

[target.'cfg(windows)'.build-dependencies]
winres = "^0.1.6"
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn fetch_and_extract_new_version(
Ok(())
}

fn update_filter() -> Result<(), Box<dyn Error>> {
fn update_filter(force: bool) -> Result<(), Box<dyn Error>> {
// Determine the directory on the filesystem, where PoE filters should live.
let local_dir = determine_poe_dir()?;
println!(
Expand Down Expand Up @@ -210,7 +210,7 @@ fn update_filter() -> Result<(), Box<dyn Error>> {
println!();

// If the tag names are equal, then return.
if current_version == latest_release.tag_name {
if current_version == latest_release.tag_name && !force {
println!("Latest version is already installed, doing nothing...");
return Ok(());
}
Expand All @@ -226,7 +226,9 @@ fn update_filter() -> Result<(), Box<dyn Error>> {
}

fn main() {
if let Err(err) = update_filter() {
let force = std::env::args().any(|e| e == "-f");

if let Err(err) = update_filter(force) {
println!("Error updating filter: {}", err);
process::exit(1);
}
Expand Down

0 comments on commit 46c8de9

Please sign in to comment.