Причёсинг

This commit is contained in:
2026-04-15 21:17:14 +03:00
parent 11fc697771
commit 9c73a8672e
7 changed files with 641 additions and 95 deletions

View File

@@ -1,3 +1,4 @@
use log;
use reqwest::{
multipart::{Form, Part},
Client, ClientBuilder,
@@ -457,19 +458,14 @@ impl SynologyClient {
url = format!("{}?{}", url, param_parts.join("&"));
}
let debug = std::env::var("SYNO_DEBUG").unwrap_or_default() == "1";
if debug {
eprintln!("[DEBUG] Request URL: {}", url);
}
log::debug!("Request URL: {}", url);
let response = self.client.get(&url).send().await?;
let status = response.status();
if !status.is_success() {
let error_text = response.text().await?;
if debug {
eprintln!("[DEBUG] Error response: {}", error_text);
}
log::debug!("Error response: {}", error_text);
return Err(SynologyError::Api {
code: status.as_u16() as i64,
message: Some(error_text),
@@ -477,10 +473,7 @@ impl SynologyClient {
}
let response_text = response.text().await?;
if debug {
eprintln!("[DEBUG] Response: {}", response_text);
}
log::debug!("Response: {}", response_text);
let api_response: ApiResponse<T> = serde_json::from_str(&response_text)
.map_err(|e| SynologyError::InvalidResponseFormat(e.to_string()))?;
@@ -501,7 +494,7 @@ impl SynologyClient {
})
}
}
/// Выполнение запроса с SID
async fn request_auth<T: DeserializeOwned + Default>(
&self,
@@ -1252,8 +1245,7 @@ impl SynologyClient {
self.sid.as_ref().unwrap_or(&String::new())
);
println!(" 🔍 Searching for file: {} in path: {}", name, path);
log::debug!("Searching for file: {} in path: {}", name, path);
let response = self
.client
.post(&url)
@@ -1287,7 +1279,7 @@ impl SynologyClient {
self.sid.as_ref().unwrap_or(&String::new())
);
println!(" 🔍 Searching for file: {}", name);
log::debug!("Searching for file: {}", name);
let response = self
.client
@@ -1325,8 +1317,7 @@ impl SynologyClient {
);
let url = format!("{}/webapi/{}", self.base_url, endpoint);
println!(" 📤 Export URL: {}", url);
log::debug!("Export URL: {}", url);
let response = self
.client
.post(&url)
@@ -1346,8 +1337,7 @@ impl SynologyClient {
}
let bytes = response.bytes().await?;
println!(" ✅ Got {} bytes", bytes.len());
log::debug!("Received {} bytes", bytes.len());
Ok(bytes.to_vec())
}
}