format the rust sources and split the functions that pushed over the line

This commit is contained in:
2026-09-21 06:33:23 +03:00
parent 205f68222c
commit 4125d509cc
10 changed files with 611 additions and 326 deletions
+17 -8
View File
@@ -157,7 +157,9 @@ impl Default for CaptureConfig {
impl Default for UpdatesConfig {
fn default() -> Self {
Self { check_on_launch: true }
Self {
check_on_launch: true,
}
}
}
@@ -213,9 +215,7 @@ impl Config {
}
pub fn needs_first_run(&self) -> bool {
self.hotkeys.start.is_none()
|| self.hotkeys.stop.is_none()
|| self.hotkeys.pause.is_none()
self.hotkeys.start.is_none() || self.hotkeys.stop.is_none() || self.hotkeys.pause.is_none()
}
}
@@ -230,16 +230,23 @@ pub(crate) fn config_path(app_dir: &Path) -> PathBuf {
/// name has no timestamp and is kept as the most recent safety net).
fn sweep_stale_backups(config_path: &Path) {
const MAX_AGE_SECS: u64 = 30 * 24 * 3600;
let Some(dir) = config_path.parent() else { return };
let Some(dir) = config_path.parent() else {
return;
};
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_or(0, |d| d.as_secs());
let Ok(entries) = std::fs::read_dir(dir) else { return };
let Ok(entries) = std::fs::read_dir(dir) else {
return;
};
for entry in entries.flatten() {
let name = entry.file_name();
let Some(name) = name.to_str() else { continue };
// Match config-{digits}.toml.bak - extract the unix secs and age it out.
if let Some(rest) = name.strip_prefix("config-").and_then(|s| s.strip_suffix(".toml.bak")) {
if let Some(rest) = name
.strip_prefix("config-")
.and_then(|s| s.strip_suffix(".toml.bak"))
{
if let Ok(ts) = rest.parse::<u64>() {
if now.saturating_sub(ts) > MAX_AGE_SECS {
drop(std::fs::remove_file(entry.path()));
@@ -273,7 +280,9 @@ mod tests {
stop: Some("F10".to_string()),
pause: Some("F11".to_string()),
},
updates: UpdatesConfig { check_on_launch: false },
updates: UpdatesConfig {
check_on_launch: false,
},
output_dir: Some(PathBuf::from("./custom")),
theme: Theme::Light,
};