diff --git a/src-tauri/src/encode.rs b/src-tauri/src/encode.rs index 93c7d8f..2deb55e 100644 --- a/src-tauri/src/encode.rs +++ b/src-tauri/src/encode.rs @@ -532,27 +532,28 @@ fn calibrate_via_sample( let sample_dur = 2.0_f64.min(req.duration_secs); let sample_start = (req.duration_secs / 2.0 - sample_dur / 2.0).max(0.0); - // Build a throwaway request scoped to the sample window. - let mut sample_req = req.clone(); - sample_req.output = sample_path.clone(); - sample_req.trim_start_secs = Some(sample_start); - sample_req.trim_end_secs = Some(sample_start + sample_dur); - sample_req.deleted_frame_indices.clear(); - sample_req.clicks.clear(); - sample_req.progress_tx = None; + // Defer cleanup until we've measured the sample: the guard owns a copy of + // the path, which lets the original move into the request below. Earlier + // versions removed the file here, which made the metadata read always fail + // and the whole calibration path silently no-op. + let sample_bytes; + { + let _guard = TempFileGuard(sample_path.clone()); - let result = encode_gif_pass(ffmpeg, &sample_req, est_width, est_fps, 1, 1); - // Defer cleanup until we've measured the sample. Earlier versions removed - // the file here, which made the metadata read below always fail and the - // whole calibration path silently no-op. - let _guard = TempFileGuard(sample_path.clone()); - if result.is_err() { - return None; + // Build a throwaway request scoped to the sample window. + let mut sample_req = req.clone(); + sample_req.output = sample_path; + sample_req.trim_start_secs = Some(sample_start); + sample_req.trim_end_secs = Some(sample_start + sample_dur); + sample_req.deleted_frame_indices.clear(); + sample_req.clicks.clear(); + sample_req.progress_tx = None; + + if encode_gif_pass(ffmpeg, &sample_req, est_width, est_fps, 1, 1).is_err() { + return None; + } + sample_bytes = std::fs::metadata(&_guard.0).map(|m| m.len()).ok()?; } - let sample_bytes = match std::fs::metadata(&sample_path) { - Ok(m) => m.len(), - Err(_) => return None, - }; if sample_bytes == 0 { return None; } @@ -1118,13 +1119,13 @@ pub(crate) fn concat_segments(ffmpeg: &Path, segments: &[PathBuf], output: &Path let list_path = parent.join("concat-list.txt"); let _guard = TempFileGuard(list_path.clone()); + use std::fmt::Write as _; let mut body = String::new(); for seg in segments { let s = seg .to_str() .ok_or_else(|| anyhow!("segment path is not UTF-8"))? .replace('\\', "/"); - use std::fmt::Write as _; let _ = writeln!(body, "file '{s}'"); } std::fs::write(&list_path, body).context("writing concat list")?; diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 92991ac..fc00e51 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -2126,7 +2126,9 @@ pub fn run() { let cfg = lock(&st.config).clone(); (cfg.updates.check_on_launch, cfg) }; - drop(register_hotkeys(app.handle(), &cfg)); + // Result is not Drop, so the old drop() here did nothing beyond + // extending its lifetime; the hotkey outcome is logged upstream. + let _hotkeys = register_hotkeys(app.handle(), &cfg); { let st = app.state::(); start_overlay_clickthrough_poll( diff --git a/src-tauri/src/updates.rs b/src-tauri/src/updates.rs index 67a5a60..02d8030 100644 --- a/src-tauri/src/updates.rs +++ b/src-tauri/src/updates.rs @@ -186,9 +186,9 @@ fn is_newer(latest: &str, current: &str) -> bool { } match (&l.pre, &c.pre) { (None, Some(_)) => true, - (Some(_), None) => false, (Some(a), Some(b)) => a > b, - (None, None) => false, + // A prerelease never outranks a stable tag of the same version. + (Some(_) | None, None) => false, } }