@@ -1,4 +1,4 @@
|
|||||||
use crate::handlers::server::get_json_server_url;
|
use crate::handlers::server::{get_json_server_url, get_target_arch_to_store};
|
||||||
use crate::models::download::{
|
use crate::models::download::{
|
||||||
DownloadTask, DownloadTaskResponse, InstallStatus, InstallTask, ResponseStatus,
|
DownloadTask, DownloadTaskResponse, InstallStatus, InstallTask, ResponseStatus,
|
||||||
};
|
};
|
||||||
@@ -556,6 +556,7 @@ impl DownloadManager {
|
|||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
println!("安装成功完成");
|
println!("安装成功完成");
|
||||||
println!("命令输出: {}", String::from_utf8_lossy(&output.stdout));
|
println!("命令输出: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
let _ = self.update_download_count(&task.category, &task.pkgname).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let error_msg = String::from_utf8_lossy(&output.stderr).to_string();
|
let error_msg = String::from_utf8_lossy(&output.stderr).to_string();
|
||||||
@@ -573,4 +574,32 @@ impl DownloadManager {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新下载量统计
|
||||||
|
pub async fn update_download_count(&self, category: &str, pkgname: &str) -> Result<(), String> {
|
||||||
|
let url = "https://feedback.spark-app.store/handle_post";
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
|
||||||
|
let json_body = serde_json::json!({
|
||||||
|
"path": format!("{}/{}/{}",get_target_arch_to_store(),category,pkgname)
|
||||||
|
});
|
||||||
|
|
||||||
|
match client
|
||||||
|
.post(url)
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.header("User-Agent", UA)
|
||||||
|
.json(&json_body)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => {
|
||||||
|
println!("下载量统计更新成功");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("下载量统计更新失败: {}", e);
|
||||||
|
Err(format!("下载量统计更新失败: {}", e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user