mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-13 00:19:31 -05:00
Bail if monero wallet rpc is not found in downloaded archive
Previously we were ignoring if the monero wallet rpc was not found and unpacked from archive leading to a failure down the line when trying to run a non-existent executable. Bail when the executable is no found in the archive.
This commit is contained in:
parent
17278d1278
commit
27df9128be
@ -1,5 +1,5 @@
|
|||||||
use ::monero::Network;
|
use ::monero::Network;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use async_compression::tokio::bufread::BzDecoder;
|
use async_compression::tokio::bufread::BzDecoder;
|
||||||
use big_bytes::BigByte;
|
use big_bytes::BigByte;
|
||||||
use futures::{StreamExt, TryStreamExt};
|
use futures::{StreamExt, TryStreamExt};
|
||||||
@ -31,6 +31,10 @@ compile_error!("unsupported operating system");
|
|||||||
|
|
||||||
const PACKED_FILE: &str = "monero-wallet-rpc";
|
const PACKED_FILE: &str = "monero-wallet-rpc";
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, thiserror::Error)]
|
||||||
|
#[error("monero wallet rpc executable not found in downloaded archive")]
|
||||||
|
pub struct ExecutableNotFoundInArchive;
|
||||||
|
|
||||||
pub struct WalletRpcProcess {
|
pub struct WalletRpcProcess {
|
||||||
_child: Child,
|
_child: Child,
|
||||||
port: u16,
|
port: u16,
|
||||||
@ -109,17 +113,22 @@ impl WalletRpc {
|
|||||||
let mut ar = Archive::new(file);
|
let mut ar = Archive::new(file);
|
||||||
let mut entries = ar.entries()?;
|
let mut entries = ar.entries()?;
|
||||||
|
|
||||||
while let Some(file) = entries.next().await {
|
loop {
|
||||||
let mut f = file?;
|
match entries.next().await {
|
||||||
if f.path()?
|
Some(file) => {
|
||||||
.to_str()
|
let mut f = file?;
|
||||||
.context("Could not find convert path to str in tar ball")?
|
if f.path()?
|
||||||
.contains(PACKED_FILE)
|
.to_str()
|
||||||
{
|
.context("Could not find convert path to str in tar ball")?
|
||||||
f.unpack(monero_wallet_rpc.exec_path()).await?;
|
.contains(PACKED_FILE)
|
||||||
|
{
|
||||||
|
f.unpack(monero_wallet_rpc.exec_path()).await?;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => bail!(ExecutableNotFoundInArchive),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_file(monero_wallet_rpc.tar_path()).await?;
|
remove_file(monero_wallet_rpc.tar_path()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user