From 9bd2ad8089fe8da6bb7227c22cf35117d484196b Mon Sep 17 00:00:00 2001 From: user Date: Fri, 28 Aug 2026 02:29:06 +0800 Subject: [PATCH] fix(cli): gate Linux-only self-update symbols behind cfg(unix) The CLI self-update module installs only on Linux: install_archive has a #[cfg(not(unix))] stub twin and every consumer of GzDecoder, Cursor, Archive, DEPRECATION_WARNING, find_package_dir, validate_entrypoint_pair, validate_plugin_host_resources and copy_plugin_host_resources lives in the #[cfg(unix)] install path. On Windows builds rustc therefore reports these symbols as unused/dead code (unused import `flate2::read::GzDecoder`, `std::io::Cursor`, `tar::Archive`, unused const `DEPRECATION_WARNING`, dead functions `find_package_dir`, `validate_entrypoint_pair`, `validate_plugin_host_resources`, `copy_plugin_host_resources` in the upstream CI build logs). Gate exactly these eight symbols with #[cfg(unix)] so Windows builds no longer emit the warnings while the Linux install path stays unchanged. Adopted-from: taiji 80820986b (import/const gate hunks) and taiji 931acc0c6 (validate/copy_plugin_host_resources gate hunks). Test: cargo check --locked -p bitfun-cli on Windows, exit 0, no remaining warnings for the self_update module. AI: implemented with AI assistance, lightly tested (cargo check only). --- src/apps/cli/src/self_update.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apps/cli/src/self_update.rs b/src/apps/cli/src/self_update.rs index 7f17be4526..f2206ddf07 100644 --- a/src/apps/cli/src/self_update.rs +++ b/src/apps/cli/src/self_update.rs @@ -1,20 +1,24 @@ use anyhow::{anyhow, Context, Result}; +#[cfg(unix)] use flate2::read::GzDecoder; use futures_util::StreamExt; use reqwest::Client; use serde::Deserialize; use sha2::{Digest, Sha256}; use std::fs; +#[cfg(unix)] use std::io::Cursor; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::time::{Duration, Instant, SystemTime}; +#[cfg(unix)] use tar::Archive; const GITHUB_MANIFEST: &str = "https://github.com/GCWing/BitFun/releases/latest/download/linux-binaries.json"; const OPENBITFUN_MANIFEST: &str = "https://openbitfun.com/release/linux-binaries.json"; const AUTO_CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60); +#[cfg(unix)] const DEPRECATION_WARNING: &str = "Warning: `bitfun-cli` is deprecated; use `bitfun` instead."; /// Source-selection tuning. Mirrors the relay deploy path in @@ -1163,6 +1167,7 @@ fn install_archive(_archive: &[u8], _current_exe: &Path) -> Result<()> { Err(anyhow!("CLI self-update is only available on Linux")) } +#[cfg(unix)] fn find_package_dir(root: &Path) -> Result { for entry in fs::read_dir(root).context("inspect CLI update archive")? { let path = entry?.path(); @@ -1175,6 +1180,7 @@ fn find_package_dir(root: &Path) -> Result { )) } +#[cfg(unix)] fn validate_entrypoint_pair(primary: &Path, legacy: &Path) -> Result<()> { let primary_status = Command::new(primary) .arg("--version") @@ -1198,6 +1204,7 @@ fn validate_entrypoint_pair(primary: &Path, legacy: &Path) -> Result<()> { Ok(()) } +#[cfg(unix)] fn validate_plugin_host_resources(directory: &Path) -> Result<()> { for entry in ["extension-host.js"] { let path = directory.join(entry); @@ -1211,6 +1218,7 @@ fn validate_plugin_host_resources(directory: &Path) -> Result<()> { Ok(()) } +#[cfg(unix)] fn copy_plugin_host_resources(source: &Path, destination: &Path) -> Result<()> { fs::create_dir_all(destination).with_context(|| { format!(