fix: windows path default lmdb

This commit is contained in:
Cyrix126 2024-10-11 20:25:01 +02:00
parent 4b0f923316
commit 0899026e91

View file

@ -5,8 +5,6 @@ use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
use std::os::windows::fs::MetadataExt; use std::os::windows::fs::MetadataExt;
#[cfg(target_os = "windows")]
use std::path::PathBuf;
use std::{ use std::{
path::Path, path::Path,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
@ -268,11 +266,7 @@ impl Helper {
PubNodeApi::update_from_output(pub_api, &output_pub, start.elapsed()); PubNodeApi::update_from_output(pub_api, &output_pub, start.elapsed());
// update data from api // update data from api
debug!("Node Watchdog | Attempting HTTP API request..."); debug!("Node Watchdog | Attempting HTTP API request...");
#[cfg(target_os = "windows")] match PrivNodeApi::request_api(&client, &state).await {
let rep = PrivNodeApi::request_api(&client, &state, path.clone()).await;
#[cfg(not(target_os = "windows"))]
let rep = PrivNodeApi::request_api(&client, &state).await;
match rep {
Ok(priv_api) => { Ok(priv_api) => {
debug!( debug!(
"Node Watchdog | HTTP API request OK, attempting [update_from_priv()]" "Node Watchdog | HTTP API request OK, attempting [update_from_priv()]"
@ -402,7 +396,6 @@ impl PrivNodeApi {
async fn request_api( async fn request_api(
client: &Client, client: &Client,
state: &Node, state: &Node,
#[cfg(target_os = "windows")] mut path: PathBuf,
) -> std::result::Result<Self, anyhow::Error> { ) -> std::result::Result<Self, anyhow::Error> {
let adr = format!("http://{}:{}/json_rpc", state.api_ip, state.api_port); let adr = format!("http://{}:{}/json_rpc", state.api_ip, state.api_port);
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
@ -428,10 +421,7 @@ impl PrivNodeApi {
if let Ok(metadata) = std::fs::metadata(if !state.path_db.is_empty() { if let Ok(metadata) = std::fs::metadata(if !state.path_db.is_empty() {
state.path_db.clone() state.path_db.clone()
} else { } else {
// take full path of monerod witout binary and add db since it's the default. r#"C:\ProgramData\bitmonero\"#.to_string()
path.pop();
path.push("db");
path.to_str().unwrap_or_default().to_string()
}) { }) {
private.result.database_size = metadata.file_size(); private.result.database_size = metadata.file_size();
} }