Skip to content

Commit

Permalink
Updated update method
Browse files Browse the repository at this point in the history
  • Loading branch information
Azuyamat committed Nov 20, 2023
1 parent c3021eb commit e4f8b7c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Binary file removed mia.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl From<ConfyError> for Error {
}

impl From<std::io::Error> for Error {
fn from(_error: std::io::Error) -> Self {
Error::ConfigActionError("Failed to execute I/O action".to_string())
fn from(error: std::io::Error) -> Self {
Error::IO(error)
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod error;
mod release;
mod languages;

use std::fs;
use std::fs::{File, OpenOptions};
use std::string::ToString;
use std::time::Instant;
Expand Down Expand Up @@ -104,9 +105,15 @@ fn main() -> Result<(), Error> {
println!("Updating Mia to {color_bright_green}{ver}{color_reset}");

let start = Instant::now();
let mut file = find_or_create_file("mia.exe")?;
let mut file = find_or_create_file("mia-tmp.exe")?;
println!("Downloading asset...");
let download_link = get_download_link_for_asset(&ver)?;
download_asset(&download_link, &mut file)?;
println!("Downloaded asset.");
println!("Renaming mia.exe to mia-old.exe");
fs::rename("mia.exe", "mia-old.exe")?;
println!("Renaming mia-tmp.exe to mia.exe");
fs::rename("mia-tmp.exe", "mia.exe")?;
let elapsed = start.elapsed().as_millis();

ver = match &version {
Expand Down

0 comments on commit e4f8b7c

Please sign in to comment.