diff --git a/.github/workflows/build-binary.yaml b/.github/workflows/build-binary.yaml index a2aafd7..6fce53c 100644 --- a/.github/workflows/build-binary.yaml +++ b/.github/workflows/build-binary.yaml @@ -68,6 +68,8 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + with: + fetch-tags: true - name: Download Web Build Artifact uses: actions/download-artifact@v4 with: diff --git a/crates/bili_sync/src/config/clap.rs b/crates/bili_sync/src/config/clap.rs index 7f42011..d9e27c1 100644 --- a/crates/bili_sync/src/config/clap.rs +++ b/crates/bili_sync/src/config/clap.rs @@ -1,7 +1,9 @@ +use std::borrow::Cow; + use clap::Parser; #[derive(Parser)] -#[command(name = "Bili-Sync", version = version(), about, long_about = None)] +#[command(name = "Bili-Sync", version = detail_version(), about, long_about = None)] pub struct Args { #[arg(short, long, env = "SCAN_ONLY")] pub scan_only: bool, @@ -14,19 +16,22 @@ mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); } -fn version() -> String { - let version = if let (Some(git_version), Some(git_dirty)) = (built_info::GIT_VERSION, built_info::GIT_DIRTY) { - format!("{}{}", git_version, if git_dirty { "-dirty" } else { "" }) +pub fn version() -> Cow<'static, str> { + if let (Some(git_version), Some(git_dirty)) = (built_info::GIT_VERSION, built_info::GIT_DIRTY) { + Cow::Owned(format!("{}{}", git_version, if git_dirty { "-dirty" } else { "" })) } else { - built_info::PKG_VERSION.to_owned() - }; + Cow::Borrowed(built_info::PKG_VERSION) + } +} + +fn detail_version() -> String { format!( "{} Architecture: {}-{} Author: {} Built Time: {} Rustc Version: {}", - version, + version(), built_info::CFG_OS, built_info::CFG_TARGET_ARCH, built_info::PKG_AUTHORS, diff --git a/crates/bili_sync/src/config/global.rs b/crates/bili_sync/src/config/global.rs index 436d39d..b95ded1 100644 --- a/crates/bili_sync/src/config/global.rs +++ b/crates/bili_sync/src/config/global.rs @@ -40,6 +40,7 @@ pub static CONFIG_DIR: Lazy = #[cfg(not(test))] fn load_config() -> Config { + info!("开始加载配置文件.."); let config = Config::load().unwrap_or_else(|err| { if err .downcast_ref::() @@ -47,7 +48,7 @@ fn load_config() -> Config { { panic!("加载配置文件失败,错误为: {err}"); } - warn!("配置文件不存在,使用默认配置..."); + warn!("配置文件不存在,使用默认配置.."); Config::default() }); info!("配置文件加载完毕,覆盖刷新原有配置"); diff --git a/crates/bili_sync/src/config/mod.rs b/crates/bili_sync/src/config/mod.rs index 7580259..66837c1 100644 --- a/crates/bili_sync/src/config/mod.rs +++ b/crates/bili_sync/src/config/mod.rs @@ -14,6 +14,7 @@ mod item; use crate::adapter::Args; use crate::bilibili::{CollectionItem, Credential, DanmakuOption, FilterOption}; +pub use crate::config::clap::version; pub use crate::config::global::{ARGS, CONFIG, CONFIG_DIR, TEMPLATE}; use crate::config::item::{ConcurrentLimit, deserialize_collection_list, serialize_collection_list}; pub use crate::config::item::{NFOTimeType, PathSafeTemplate, RateLimit, WatchLaterConfig}; diff --git a/crates/bili_sync/src/main.rs b/crates/bili_sync/src/main.rs index 2728c4d..80d561b 100644 --- a/crates/bili_sync/src/main.rs +++ b/crates/bili_sync/src/main.rs @@ -59,10 +59,11 @@ fn spawn_task( }); } -/// 初始化日志系统,加载命令行参数和配置文件 +/// 初始化日志系统,打印欢迎信息,加载配置文件 fn init() { - Lazy::force(&ARGS); init_logger(&ARGS.log_level); + info!("欢迎使用 Bili-Sync,当前程序版本:{}", config::version()); + info!("项目地址:https://github.com/amtoaer/bili-sync"); Lazy::force(&CONFIG); } diff --git a/crates/bili_sync/src/task/http_server.rs b/crates/bili_sync/src/task/http_server.rs index 3c9cce8..0dc52b6 100644 --- a/crates/bili_sync/src/task/http_server.rs +++ b/crates/bili_sync/src/task/http_server.rs @@ -42,7 +42,7 @@ pub async fn http_server(database_connection: Arc) -> Result let listener = tokio::net::TcpListener::bind(&CONFIG.bind_address) .await .context("bind address failed")?; - info!("开始监听 http 服务: http://{}", CONFIG.bind_address); + info!("开始运行管理页: http://{}", CONFIG.bind_address); Ok(axum::serve(listener, ServiceExt::::into_make_service(app)).await?) } diff --git a/crates/bili_sync/src/task/video_downloader.rs b/crates/bili_sync/src/task/video_downloader.rs index a83ac4b..81976c4 100644 --- a/crates/bili_sync/src/task/video_downloader.rs +++ b/crates/bili_sync/src/task/video_downloader.rs @@ -13,6 +13,7 @@ pub async fn video_downloader(connection: Arc) { let bili_client = BiliClient::new(); let video_sources = CONFIG.as_video_sources(); loop { + info!("开始执行本轮视频下载任务.."); 'inner: { match bili_client.wbi_img().await.map(|wbi_img| wbi_img.into()) { Ok(Some(mixin_key)) => bilibili::set_global_mixin_key(mixin_key),