mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-30 02:40:03 +08:00
ref fn
This commit is contained in:
@@ -10,7 +10,7 @@ use rust_util::{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::http::get_url;
|
use super::http::get_url_content;
|
||||||
use super::misc::VERBOSE;
|
use super::misc::VERBOSE;
|
||||||
|
|
||||||
pub const BUILD_JSON: &str = "build.json";
|
pub const BUILD_JSON: &str = "build.json";
|
||||||
@@ -21,12 +21,13 @@ pub fn get_archive_version(gid: &str, aid: &str) -> XResult<String> {
|
|||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("Start get archive info: {}:{}", gid, aid));
|
print_message(MessageType::DEBUG, &format!("Start get archive info: {}:{}", gid, aid));
|
||||||
}
|
}
|
||||||
let mut url = String::from(GET_ARCHIVER_VERSION_URL);
|
let mut url = String::with_capacity(1024);
|
||||||
|
url.push_str(GET_ARCHIVER_VERSION_URL);
|
||||||
url.push_str("?gid=");
|
url.push_str("?gid=");
|
||||||
url.push_str(&urlencoding::encode(gid));
|
url.push_str(&urlencoding::encode(gid));
|
||||||
url.push_str("&aid=");
|
url.push_str("&aid=");
|
||||||
url.push_str(&urlencoding::encode(aid));
|
url.push_str(&urlencoding::encode(aid));
|
||||||
let version_result = get_url(url.as_str())?;
|
let version_result = get_url_content(url.as_str())?;
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("Get archive result: {}", version_result));
|
print_message(MessageType::DEBUG, &format!("Get archive result: {}", version_result));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub fn download_url(url: &str, dest: &mut File) -> XResult<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_url(url: &str) -> XResult<String> {
|
pub fn get_url_content(url: &str) -> XResult<String> {
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
print_message(MessageType::DEBUG, &format!("Get URL: {}", url));
|
print_message(MessageType::DEBUG, &format!("Get URL: {}", url));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use rust_util::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use super::{
|
use super::{
|
||||||
http,
|
http::{ download_url, get_url_content, },
|
||||||
local_util::{self, *},
|
local_util::{self, *},
|
||||||
misc::*,
|
misc::*,
|
||||||
};
|
};
|
||||||
@@ -200,7 +200,7 @@ pub fn get_tool_package_detail(name: &str, version: &str) -> XResult<String> {
|
|||||||
url.push_str(&urlencoding::encode(name));
|
url.push_str(&urlencoding::encode(name));
|
||||||
url.push_str("&ver=");
|
url.push_str("&ver=");
|
||||||
url.push_str(&urlencoding::encode(version));
|
url.push_str(&urlencoding::encode(version));
|
||||||
Ok(http::get_url(url.as_str())?)
|
Ok(get_url_content(url.as_str())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_and_extract_tool_package(base_dir: &str, dir_with_name: bool, name: &str, version: &str, extract_match: bool) -> XResult<bool> {
|
pub fn get_and_extract_tool_package(base_dir: &str, dir_with_name: bool, name: &str, version: &str, extract_match: bool) -> XResult<bool> {
|
||||||
@@ -236,7 +236,7 @@ pub fn get_and_extract_tool_package(base_dir: &str, dir_with_name: bool, name: &
|
|||||||
let target_file_name = format!("{}/{}", &target_base_dir, name.to_string());
|
let target_file_name = format!("{}/{}", &target_base_dir, name.to_string());
|
||||||
|
|
||||||
print_message(MessageType::INFO, &format!("Start download: {} -> {}", &url.to_string(), &target_file_name));
|
print_message(MessageType::INFO, &format!("Start download: {} -> {}", &url.to_string(), &target_file_name));
|
||||||
http::download_url(&url.to_string(), &mut File::create(&target_file_name)?)?;
|
download_url(&url.to_string(), &mut File::create(&target_file_name)?)?;
|
||||||
|
|
||||||
print_message(MessageType::INFO, &format!("Start verify integrity: {} ...", &target_file_name));
|
print_message(MessageType::INFO, &format!("Start verify integrity: {} ...", &target_file_name));
|
||||||
if local_util::verify_file_integrity(&integrity.to_string(), &target_file_name)? {
|
if local_util::verify_file_integrity(&integrity.to_string(), &target_file_name)? {
|
||||||
|
|||||||
Reference in New Issue
Block a user