Skip to content

Commit

Permalink
fix: file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
megatank58 committed Oct 9, 2022
1 parent 0bc114e commit 90b9838
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.6.0
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
[package]
name = "oxup"
version = "2.5.0"
version = "2.6.0"
edition = "2021"

[profile.release]
Expand Down
30 changes: 16 additions & 14 deletions src/install.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::os::unix::prelude::OpenOptionsExt;

use crate::{info, success};
use reqwest::{
header::{HeaderMap, USER_AGENT},
Expand Down Expand Up @@ -30,11 +32,7 @@ pub async fn install(os: OS, oxup: bool) -> Result<(), Box<dyn std::error::Error
let response = client.get(target).headers(headers.clone()).send().await?;
let result: ReleaseData = response.json().await?;

let bin = if oxup {
"oxup"
} else {
"oxido"
};
let bin = if oxup { "oxup" } else { "oxido" };

let filter = &match os {
OS::Mac => bin.to_owned() + "darwin",
Expand All @@ -56,15 +54,19 @@ pub async fn install(os: OS, oxup: bool) -> Result<(), Box<dyn std::error::Error

info!["Moving package"];

std::fs::write(
match os {
OS::Windows => format!(r"C:\bin\{bin}.exe"),
_ => {
format!("{}/.oxido/bin/{bin}", std::env::var("HOME").unwrap())
}
},
bytes,
)?;
match os {
OS::Windows => std::fs::write(format!(r"C:\bin\{bin}.exe"), bytes)?,
_ => {
std::fs::OpenOptions::new()
.create(true)
.write(true)
.mode(0o770)
.open(format!(
"{}/.oxido/bin/{bin}",
std::env::var("HOME").unwrap()
))?;
}
}

success![format!("{bin} has been installed!")];

Expand Down

0 comments on commit 90b9838

Please sign in to comment.