tighten visibility and clear the remaining mechanical lint noise

This commit is contained in:
2026-09-21 00:44:25 +03:00
parent 1332600148
commit 03b2fec744
11 changed files with 158 additions and 172 deletions
+13 -14
View File
@@ -8,7 +8,7 @@ const GITEA_LATEST: &str =
"https://git.lashman.live/api/v1/repos/lashman/bytesize/releases/latest";
#[derive(Debug, Clone, Serialize)]
pub struct UpdateInfo {
pub(crate) struct UpdateInfo {
pub version: String,
pub current_version: String,
pub release_url: String,
@@ -31,7 +31,7 @@ struct GiteaAsset {
browser_download_url: String,
}
pub async fn check_for_update() -> Result<Option<UpdateInfo>> {
pub(crate) async fn check_for_update() -> Result<Option<UpdateInfo>> {
let client = reqwest::Client::builder()
.user_agent(concat!("ByteSize/", env!("CARGO_PKG_VERSION")))
.build()?;
@@ -63,7 +63,7 @@ pub async fn check_for_update() -> Result<Option<UpdateInfo>> {
}
}
pub async fn download_to<F>(url: &str, dest: &Path, mut on_progress: F) -> Result<()>
pub(crate) async fn download_to<F>(url: &str, dest: &Path, mut on_progress: F) -> Result<()>
where
F: FnMut(u64, Option<u64>) + Send,
{
@@ -89,7 +89,7 @@ where
Ok(())
}
pub fn pending_update_path(app_dir: &Path) -> PathBuf {
pub(crate) fn pending_update_path(app_dir: &Path) -> PathBuf {
app_dir.join("ByteSize.new.exe")
}
@@ -99,7 +99,7 @@ fn last_check_path(app_dir: &Path) -> PathBuf {
/// Returns true if the last successful update check happened more than `ttl`
/// ago, or never. The stamp file's mtime is the source of truth.
pub fn should_check(app_dir: &Path, ttl: std::time::Duration) -> bool {
pub(crate) fn should_check(app_dir: &Path, ttl: std::time::Duration) -> bool {
let path = last_check_path(app_dir);
let Ok(meta) = std::fs::metadata(&path) else {
return true;
@@ -113,7 +113,7 @@ pub fn should_check(app_dir: &Path, ttl: std::time::Duration) -> bool {
elapsed > ttl
}
pub fn stamp_check(app_dir: &Path) {
pub(crate) fn stamp_check(app_dir: &Path) {
let path = last_check_path(app_dir);
if let Some(parent) = path.parent() {
drop(std::fs::create_dir_all(parent));
@@ -121,11 +121,11 @@ pub fn stamp_check(app_dir: &Path) {
drop(std::fs::write(&path, b""));
}
pub fn has_pending_update(app_dir: &Path) -> bool {
pub(crate) fn has_pending_update(app_dir: &Path) -> bool {
pending_update_path(app_dir).is_file()
}
pub fn write_apply_script(app_dir: &Path) -> Result<PathBuf> {
pub(crate) fn write_apply_script(app_dir: &Path) -> Result<PathBuf> {
let bat_path = app_dir.join("bytesize-apply-update.bat");
let exe_name = std::env::current_exe()
.ok()
@@ -135,21 +135,20 @@ pub fn write_apply_script(app_dir: &Path) -> Result<PathBuf> {
"@echo off\r\n\
timeout /t 3 /nobreak >nul\r\n\
:retry\r\n\
del \"%~dp0{exe}\" 2>nul\r\n\
if exist \"%~dp0{exe}\" (\r\n\
del \"%~dp0{exe_name}\" 2>nul\r\n\
if exist \"%~dp0{exe_name}\" (\r\n\
timeout /t 2 /nobreak >nul\r\n\
goto retry\r\n\
)\r\n\
move /Y \"%~dp0ByteSize.new.exe\" \"%~dp0{exe}\" >nul\r\n\
move /Y \"%~dp0ByteSize.new.exe\" \"%~dp0{exe_name}\" >nul\r\n\
if errorlevel 1 (\r\n\
echo Failed to replace executable\r\n\
pause\r\n\
del \"%~f0\"\r\n\
exit /b 1\r\n\
)\r\n\
start \"\" \"%~dp0{exe}\"\r\n\
del \"%~f0\"\r\n",
exe = exe_name
start \"\" \"%~dp0{exe_name}\"\r\n\
del \"%~f0\"\r\n"
);
std::fs::write(&bat_path, body).context("writing apply script")?;
Ok(bat_path)