Skip to content

Commit ae7bd79

Browse files
ref: Simplify set_executable_mode
Don't compile the function at all for Windows (this avoids `unnecessary_wraps` lint on Windows). Partially unblocks #2360.
1 parent 71d6840 commit ae7bd79

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/utils/fs.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,14 @@ pub fn is_writable<P: AsRef<Path>>(path: P) -> bool {
136136
/// Set the mode of a path to 755 if we're on a Unix machine, otherwise
137137
/// don't do anything with the given path.
138138
#[cfg(not(feature = "managed"))]
139+
#[cfg(not(windows))]
139140
pub fn set_executable_mode<P: AsRef<Path>>(path: P) -> Result<()> {
140-
#[cfg(not(windows))]
141-
fn exec<P: AsRef<Path>>(path: P) -> io::Result<()> {
142-
use std::os::unix::fs::PermissionsExt;
143-
let mut perm = fs::metadata(&path)?.permissions();
144-
perm.set_mode(0o755);
145-
fs::set_permissions(&path, perm)
146-
}
141+
use std::os::unix::fs::PermissionsExt;
147142

148-
#[cfg(windows)]
149-
fn exec<P: AsRef<Path>>(_path: P) -> io::Result<()> {
150-
Ok(())
151-
}
143+
let mut perm = fs::metadata(&path)?.permissions();
144+
perm.set_mode(0o755);
145+
fs::set_permissions(&path, perm)?;
152146

153-
exec(path)?;
154147
Ok(())
155148
}
156149

src/utils/update.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ use crate::api::{Api, SentryCliRelease};
2020
use crate::config::Config;
2121
use crate::constants::{APP_NAME, VERSION};
2222
#[cfg(not(feature = "managed"))]
23-
use crate::utils::fs::{is_writable, set_executable_mode};
23+
use crate::utils::fs::is_writable;
24+
#[cfg(not(windows))]
25+
#[cfg(not(feature = "managed"))]
26+
use crate::utils::fs::set_executable_mode;
2427
#[cfg(not(feature = "managed"))]
2528
use crate::utils::system::QuietExit;
2629
use crate::utils::system::{is_homebrew_install, is_npm_install};
@@ -171,6 +174,7 @@ impl SentryCliUpdateInfo {
171174
}
172175
};
173176

177+
#[cfg(not(windows))]
174178
set_executable_mode(&tmp_path)?;
175179
rename_exe(&exe, &tmp_path, elevate)?;
176180
Ok(())

0 commit comments

Comments
 (0)