fix: improved the logic for generating binaries
cross platform logic wasn't handled well for generating linux binaries on windows or vice versa
This commit is contained in:
parent
81fb2ed548
commit
7876e00dc8
@ -29,11 +29,9 @@ pub async fn generate(mut name: PathBuf, port: u16, target: TargetOs) -> anyhow:
|
||||
#[cfg(unix)]
|
||||
file.mode(0o755);
|
||||
|
||||
#[cfg(windows)]
|
||||
let old_file_part = name.file_name().unwrap().to_owned();
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if matches!(target, TargetOs::Windows) {
|
||||
let mut file_part = name.file_name().unwrap().to_owned();
|
||||
file_part.push(OsString::from(".exe"));
|
||||
name.pop();
|
||||
@ -42,13 +40,16 @@ pub async fn generate(mut name: PathBuf, port: u16, target: TargetOs) -> anyhow:
|
||||
|
||||
let mut file = file.open(&name).await?;
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if matches!(target, TargetOs::Windows) {
|
||||
name.pop();
|
||||
name.push(old_file_part);
|
||||
}
|
||||
|
||||
file.write_all(SPARSE_LINUX_SERVER_BINARY).await?;
|
||||
file.write_all(match target {
|
||||
TargetOs::Windows => SPARSE_WINDOWS_SERVER_BINARY,
|
||||
TargetOs::Linux => SPARSE_LINUX_SERVER_BINARY,
|
||||
})
|
||||
.await?;
|
||||
file.write_all(CONFIG_SEPARATOR).await?;
|
||||
file.write_all(&port.to_be_bytes()[..]).await?;
|
||||
file.write_all(keypair.public.as_bytes()).await?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user