mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
fix: 0B database size on Windows
This commit is contained in:
parent
7d9724ea24
commit
e5c333861c
1 changed files with 24 additions and 6 deletions
|
@ -1,15 +1,16 @@
|
||||||
|
use enclose::enc;
|
||||||
|
use log::{debug, error, info, warn};
|
||||||
|
use readable::byte::Byte;
|
||||||
|
use reqwest::Client;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::fs::Metadata;
|
||||||
use std::{
|
use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
thread,
|
thread,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
use enclose::enc;
|
|
||||||
use log::{debug, error, info, warn};
|
|
||||||
use readable::byte::Byte;
|
|
||||||
use reqwest::Client;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use tokio::spawn;
|
use tokio::spawn;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -397,6 +398,15 @@ impl PrivNodeApi {
|
||||||
state: &Node,
|
state: &Node,
|
||||||
) -> 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")]
|
||||||
|
let mut private = client
|
||||||
|
.post(adr)
|
||||||
|
.body(r#"{"jsonrpc":"2.0","id":"0","method":"get_info"}"#)
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.json::<PrivNodeApi>()
|
||||||
|
.await?;
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
let private = client
|
let private = client
|
||||||
.post(adr)
|
.post(adr)
|
||||||
.body(r#"{"jsonrpc":"2.0","id":"0","method":"get_info"}"#)
|
.body(r#"{"jsonrpc":"2.0","id":"0","method":"get_info"}"#)
|
||||||
|
@ -404,6 +414,14 @@ impl PrivNodeApi {
|
||||||
.await?
|
.await?
|
||||||
.json::<PrivNodeApi>()
|
.json::<PrivNodeApi>()
|
||||||
.await?;
|
.await?;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
// api returns 0 for DB size for Windows so we read the size directly from the filesystem.
|
||||||
|
// https://github.com/monero-project/monero/issues/9513
|
||||||
|
{
|
||||||
|
private.result.database_size = std::fs::metadata(state.path_db)
|
||||||
|
.unwrap_or(".bitmonero")
|
||||||
|
.st_size();
|
||||||
|
}
|
||||||
Ok(private)
|
Ok(private)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue