Skip to content

Commit

Permalink
remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad committed Jul 31, 2024
1 parent 9c73489 commit 17e16e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
24 changes: 12 additions & 12 deletions src/handlers/install_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ async fn download_version(
let mut response_bytes = response.bytes_stream();

// Progress Bar Setup
// let pb = ProgressBar::new(total_size);
// pb.set_style(ProgressStyle::default_bar()
// .template("{msg}\n{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta})")
// .progress_chars("█ "));
// pb.set_message(format!("Downloading version: {}", version.tag_name));
let pb = ProgressBar::new(total_size);
pb.set_style(ProgressStyle::default_bar()
.template("{msg}\n{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta})")
.progress_chars("█ "));
pb.set_message(format!("Downloading version: {}", version.tag_name));

let file_type = helpers::get_file_type();
let mut file =
Expand All @@ -361,15 +361,15 @@ async fn download_version(
file.write_all(&chunk).await?;
let new = min(downloaded + (chunk.len() as u64), total_size);
downloaded = new;
// pb.set_position(new);
pb.set_position(new);
}

// pb.finish_with_message(format!(
// "Downloaded version {} to {}/{}.{file_type}",
// version.tag_name,
// root.display(),
// version.tag_name
// ));
pb.finish_with_message(format!(
"Downloaded version {} to {}/{}.{file_type}",
version.tag_name,
root.display(),
version.tag_name
));

Ok(PostDownloadVersionType::Standard(LocalVersion {
file_name: version.tag_name.to_owned(),
Expand Down
34 changes: 15 additions & 19 deletions src/helpers/unarchive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ fn expand(downloaded_file: LocalVersion) -> Result<()> {
let mut archive = Archive::new(decompress_stream);

let totalsize = 1692; // hard coding this is pretty unwise, but you cant get the length of an archive in tar-rs unlike zip-rs
// let pb = ProgressBar::new(totalsize);
// pb.set_style(
// ProgressStyle::default_bar()
// .template(
// "{msg}\n{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len}",
// )
// .progress_chars("█ "),
// );
// pb.set_message("Expanding archive");
let pb = ProgressBar::new(totalsize);
pb.set_style(
ProgressStyle::default_bar()
.template(
"{msg}\n{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len}",
)
.progress_chars("█ "),
);
pb.set_message("Expanding archive");

let mut downloaded: u64 = 0;
let mut display = true;

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / check (macos-latest)

unused variable: `display`

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / check (macos-latest)

variable does not need to be mutable

Check failure on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / clippy (macos-latest)

unused variable: `display`

Check failure on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / clippy (macos-latest)

variable does not need to be mutable

Check failure on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / clippy (macos-latest)

unused variable: `display`

Check failure on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / clippy (macos-latest)

variable does not need to be mutable

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `display`

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

variable does not need to be mutable

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / check (macos-latest)

unused variable: `display`

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / check (macos-latest)

variable does not need to be mutable

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unused variable: `display`

Check warning on line 320 in src/helpers/unarchive.rs

View workflow job for this annotation

GitHub Actions / test (macos-latest)

variable does not need to be mutable
Expand All @@ -324,11 +324,7 @@ fn expand(downloaded_file: LocalVersion) -> Result<()> {
let mut outpath = PathBuf::new();
outpath.push(&downloaded_file.file_name);
let no_parent_file = remove_base_parent(&file.path().unwrap()).unwrap();
outpath.push(no_parent_file.clone());
if display {
println!("{} {} {}", &outpath.display(), &no_parent_file.display(), &file.path().unwrap().display());
display = false;
}
outpath.push(no_parent_file);

let file_name = format!("{}", file.path()?.display()); // file.path()?.is_dir() always returns false... weird
if file_name.ends_with('/') {
Expand All @@ -344,15 +340,15 @@ fn expand(downloaded_file: LocalVersion) -> Result<()> {
}
let new = min(downloaded + 1, totalsize);
downloaded = new;
// pb.set_position(new);
pb.set_position(new);
}
Err(error) => println!("{error}"),
}
}
// pb.finish_with_message(format!(
// "Finished expanding to {}/{}",
// downloaded_file.path, downloaded_file.file_name
// ));
pb.finish_with_message(format!(
"Finished expanding to {}/{}",
downloaded_file.path, downloaded_file.file_name
));

let file = &format!("{}/bin/nvim", downloaded_file.file_name);
let mut perms = fs::metadata(file)?.permissions();
Expand Down

0 comments on commit 17e16e2

Please sign in to comment.