split Main into components, move gif math to backend

This commit is contained in:
2026-06-04 22:03:20 +03:00
parent b6bee70dcd
commit a48d82ddc9
8 changed files with 811 additions and 371 deletions
+28
View File
@@ -93,6 +93,34 @@ pub fn pending_update_path(app_dir: &Path) -> PathBuf {
app_dir.join("ByteSize.new.exe")
}
fn last_check_path(app_dir: &Path) -> PathBuf {
app_dir.join("temp").join("last-update-check")
}
/// 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 {
let path = last_check_path(app_dir);
let Ok(meta) = std::fs::metadata(&path) else {
return true;
};
let Ok(modified) = meta.modified() else {
return true;
};
let Ok(elapsed) = modified.elapsed() else {
return true;
};
elapsed > ttl
}
pub fn stamp_check(app_dir: &Path) {
let path = last_check_path(app_dir);
if let Some(parent) = path.parent() {
let _ = std::fs::create_dir_all(parent);
}
let _ = std::fs::write(&path, b"");
}
pub fn has_pending_update(app_dir: &Path) -> bool {
pending_update_path(app_dir).is_file()
}