split Main into components, move gif math to backend
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user