Skip to content

Commit

Permalink
fix new clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
xermicus committed Jun 2, 2021
1 parent 16f1290 commit 9b2c961
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ isahc = { version = "1.2.0", features = ["json"] }
async-compression = { version = "0.3.5", features = ["futures-write", "gzip", "bzip2", "xz", "deflate"] }
async-tar = "0.3.0"
termion = "1.5.5"
progress_string = "0.1.1"
progress_string = "0.2.0"
once_cell = "1.5.2"
20 changes: 5 additions & 15 deletions src/bspm/installer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::time::Duration;

Expand Down Expand Up @@ -225,28 +225,18 @@ pub enum Archived {
}

impl Archived {
async fn install(
&self,
ctx: &ui::Context,
src: &PathBuf,
dest: &PathBuf,
) -> anyhow::Result<()> {
async fn install(&self, ctx: &ui::Context, src: &Path, dest: &Path) -> anyhow::Result<()> {
ctx.notify(&format!("Installing into {}", dest.display()))
.await;
match &self {
Archived::None => move_exe(src, dest).await?,
Archived::None => move_exe(&src.to_path_buf(), dest).await?,
Archived::Tar => self.install_tar(ctx, src, dest).await?,
Archived::Zip => self.install_tar(ctx, src, dest).await?,
}
Ok(())
}

async fn install_tar(
&self,
ctx: &ui::Context,
src: &PathBuf,
dest: &PathBuf,
) -> anyhow::Result<()> {
async fn install_tar(&self, ctx: &ui::Context, src: &Path, dest: &Path) -> anyhow::Result<()> {
ctx.notify("Choose a file from Tar archive...").await;
let mut file_index = 0;
let archive = Archive::new(async_std::fs::File::open(src).await?);
Expand Down Expand Up @@ -341,7 +331,7 @@ impl std::str::FromStr for Compression {
}
}

async fn move_exe(src: &PathBuf, dest: &PathBuf) -> anyhow::Result<(), std::io::Error> {
async fn move_exe(src: &Path, dest: &Path) -> anyhow::Result<(), std::io::Error> {
copy(src, dest).await?;
remove_file(src).await?;
let meta = dest.metadata()?;
Expand Down
6 changes: 3 additions & 3 deletions src/bspm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub mod ui;
use ui::context;

#[derive(Serialize, Deserialize, Default, Debug)]
pub struct BSPM {
pub struct Bspm {
packages: Vec<Package>,
}

impl BSPM {
pub async fn new() -> anyhow::Result<BSPM> {
impl Bspm {
pub async fn new() -> anyhow::Result<Bspm> {
let path = cfg_path().await;
let mut buffer = String::new();
File::open(&path)
Expand Down
6 changes: 3 additions & 3 deletions src/bspm/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ impl UI {
let (stdin_send, stdin_recv) = bounded(1);
let (stdout_send, stdout_recv) = bounded(1);
UI {
stdin_send,
stdin_recv,
stdout_send,
stdout_recv,
stdin_send,
stdin_recv,
}
}

Expand All @@ -54,8 +54,8 @@ impl UI {
let stdout = self.stdout_send.clone();
Context {
name,
stdout,
stdin,
stdout,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ pub enum Command {

impl Command {
pub async fn go(&self) -> anyhow::Result<()> {
let bspm = BSPM::new()
let bspm = Bspm::new()
.await
.context("BSPM failed to start\nTry `bspm init` if you are running it the first time");
match self {
Command::Init { no_install } => {
BSPM::default().create_config().await?;
Bspm::default().create_config().await?;
if !no_install {
BSPM::new()
Bspm::new()
.await?
.install(
"blindspot".to_string(),
Expand Down

0 comments on commit 9b2c961

Please sign in to comment.