ksud: extract binaries properly (#1253)
This commit is contained in:
@@ -330,7 +330,7 @@ fn _install_module(zip: &str) -> Result<()> {
|
|||||||
// print banner
|
// print banner
|
||||||
println!(include_str!("banner"));
|
println!(include_str!("banner"));
|
||||||
|
|
||||||
assets::ensure_binaries(true).with_context(|| "Failed to extract assets")?;
|
assets::ensure_binaries(false).with_context(|| "Failed to extract assets")?;
|
||||||
|
|
||||||
// first check if workding dir is usable
|
// first check if workding dir is usable
|
||||||
ensure_dir_exists(defs::WORKING_DIR).with_context(|| "Failed to create working dir")?;
|
ensure_dir_exists(defs::WORKING_DIR).with_context(|| "Failed to create working dir")?;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use anyhow::{bail, Context, Error, Ok, Result};
|
use anyhow::{bail, Context, Error, Ok, Result};
|
||||||
use std::{
|
use std::{
|
||||||
fs::{create_dir_all, write, File, OpenOptions},
|
fs::{create_dir_all, remove_file, write, File, OpenOptions},
|
||||||
io::{ErrorKind::AlreadyExists, Write},
|
io::{ErrorKind::AlreadyExists, ErrorKind::NotFound, Write},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,6 +63,13 @@ pub fn ensure_binary<T: AsRef<Path>>(
|
|||||||
)
|
)
|
||||||
})?)?;
|
})?)?;
|
||||||
|
|
||||||
|
if let Err(e) = remove_file(path.as_ref()) {
|
||||||
|
if e.kind() != NotFound {
|
||||||
|
return Err(Error::from(e))
|
||||||
|
.with_context(|| format!("failed to unlink {}", path.as_ref().display()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
write(&path, contents)?;
|
write(&path, contents)?;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
set_permissions(&path, Permissions::from_mode(0o755))?;
|
set_permissions(&path, Permissions::from_mode(0o755))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user