Merge branch 'master' of ssh://shenjack.top:5101/shenjack/openbmclapi-rs

This commit is contained in:
BlueFunny 2024-01-27 23:26:29 +08:00
commit e1e6edd34d
No known key found for this signature in database
GPG Key ID: 3F8CF94B07FCBDB3
2 changed files with 7 additions and 19 deletions

View File

@ -1,4 +1,4 @@
use crate::config::{ClusterByoc, Config};
use crate::config::{Config};
use crate::utils::avro_data_to_file_list;
use crate::PROTOCOL_VERSION;
@ -60,11 +60,7 @@ impl Cluster {
pub async fn get_file_list(&self) -> Option<Vec<SyncFile>> {
// server: https://openbmclapi.bangbang93.com
// path: /openbmclapi/files
let url = format!(
"{}://{}/openbmclapi/files",
self.config.cluster_byoc.to_string(),
self.config.center_url.clone()
);
let url = self.config.join_center_url("/openbmclapi/files");
let password = self.config.cluster_secret.clone();
let username = self.config.cluster_id.clone();
let client = Client::builder().user_agent(self.ua.clone()).build().unwrap();
@ -111,26 +107,17 @@ mod tests {
}
fn gen_config() -> Config {
let center_url = "openbmclapi.bangbang93.com".to_string();
// 读取 config.toml 获得
let raw_config = std::fs::read_to_string("config.toml").unwrap();
let test_conf: TestConfig = toml::from_str(raw_config.as_str()).unwrap();
let cluster_byoc = ClusterByoc::https;
let no_demaon = false;
let disable_access_log = false;
let force_noopen = false;
let enable_nginx = false;
Config::new(
center_url,
None,
"".to_string(),
test_conf.cluster_port,
test_conf.cluster_id,
test_conf.cluster_secret,
cluster_byoc,
no_demaon,
disable_access_log,
force_noopen,
enable_nginx,
false,
)
}
@ -138,6 +125,6 @@ mod tests {
async fn test_get_file_list() {
let config = gen_config();
let cluster = Cluster::new(config);
cluster.get_file_list().await;
cluster.get_file_list().await.unwrap();
}
}

View File

@ -39,6 +39,7 @@ impl Config {
cluster_secret: String,
no_demaon: bool,
) -> Self {
// https://openbmclapi.bangbang93.com
Self {
center_url,
host_ip,