Compare commits
2 commits
d3434e8408
...
84941e2cb4
Author | SHA1 | Date | |
---|---|---|---|
84941e2cb4 | |||
940af6508c |
3 changed files with 8 additions and 6 deletions
2
src/cache/disk.rs
vendored
2
src/cache/disk.rs
vendored
|
@ -42,7 +42,7 @@ impl DiskCache {
|
|||
/// notifications when a file has been written.
|
||||
pub async fn new(disk_max_size: Bytes, disk_path: PathBuf) -> Arc<Self> {
|
||||
let db_pool = {
|
||||
let db_url = format!("sqlite:{}/metadata.sqlite", disk_path.to_string_lossy());
|
||||
let db_url = format!("sqlite:{}/metadata.db", disk_path.to_string_lossy());
|
||||
let mut options = SqliteConnectOptions::from_str(&db_url)
|
||||
.unwrap()
|
||||
.create_if_missing(true);
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::state::{
|
|||
RwLockServerState, PREVIOUSLY_COMPROMISED, PREVIOUSLY_PAUSED, TLS_CERTS,
|
||||
TLS_PREVIOUSLY_CREATED, TLS_SIGNING_KEY,
|
||||
};
|
||||
use crate::units::{BytesPerSecond, Mebibytes, Port};
|
||||
use crate::units::{Bytes, BytesPerSecond, Port};
|
||||
use crate::CLIENT_API_VERSION;
|
||||
|
||||
pub const CONTROL_CENTER_PING_URL: &str = "https://api.mangadex.network/ping";
|
||||
|
@ -26,7 +26,7 @@ pub const CONTROL_CENTER_PING_URL: &str = "https://api.mangadex.network/ping";
|
|||
pub struct Request<'a> {
|
||||
secret: &'a ClientSecret,
|
||||
port: Port,
|
||||
disk_space: Mebibytes,
|
||||
disk_space: Bytes,
|
||||
network_speed: BytesPerSecond,
|
||||
build_version: usize,
|
||||
tls_created_at: Option<String>,
|
||||
|
@ -41,7 +41,7 @@ impl<'a> Request<'a> {
|
|||
.external_address
|
||||
.and_then(|v| Port::new(v.port()))
|
||||
.unwrap_or(config.port),
|
||||
disk_space: config.disk_quota,
|
||||
disk_space: config.disk_quota.into(),
|
||||
network_speed: config.network_speed.into(),
|
||||
build_version: CLIENT_API_VERSION,
|
||||
tls_created_at: TLS_PREVIOUSLY_CREATED
|
||||
|
@ -60,7 +60,7 @@ impl<'a> From<(&'a ClientSecret, &Config)> for Request<'a> {
|
|||
.external_address
|
||||
.and_then(|v| Port::new(v.port()))
|
||||
.unwrap_or(config.port),
|
||||
disk_space: config.disk_quota,
|
||||
disk_space: config.disk_quota.into(),
|
||||
network_speed: config.network_speed.into(),
|
||||
build_version: CLIENT_API_VERSION,
|
||||
tls_created_at: None,
|
||||
|
@ -179,6 +179,7 @@ pub async fn update_server_state(
|
|||
let req = Request::from_config_and_state(secret, cli);
|
||||
debug!("Sending ping request: {:?}", req);
|
||||
let client = reqwest::Client::new();
|
||||
dbg!(serde_json::to_string(&req).unwrap());
|
||||
let resp = client.post(CONTROL_CENTER_PING_URL).json(&req).send().await;
|
||||
match resp {
|
||||
Ok(resp) => match resp.json::<Response>().await {
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Display for Port {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize, Deserialize, Default, Debug, Hash, Eq, PartialEq)]
|
||||
#[derive(Copy, Clone, Deserialize, Default, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct Mebibytes(usize);
|
||||
|
||||
impl Mebibytes {
|
||||
|
@ -56,6 +56,7 @@ impl FromStr for Mebibytes {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct Bytes(pub usize);
|
||||
|
||||
impl Bytes {
|
||||
|
|
Loading…
Reference in a new issue