merge duplicate arms and drop a needless clone

This commit is contained in:
2026-09-21 01:32:20 +03:00
parent 3f50fdd337
commit e6e07ca6a1
3 changed files with 26 additions and 23 deletions
+13 -12
View File
@@ -532,27 +532,28 @@ fn calibrate_via_sample(
let sample_dur = 2.0_f64.min(req.duration_secs); 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); let sample_start = (req.duration_secs / 2.0 - sample_dur / 2.0).max(0.0);
// 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());
// Build a throwaway request scoped to the sample window. // Build a throwaway request scoped to the sample window.
let mut sample_req = req.clone(); let mut sample_req = req.clone();
sample_req.output = sample_path.clone(); sample_req.output = sample_path;
sample_req.trim_start_secs = Some(sample_start); sample_req.trim_start_secs = Some(sample_start);
sample_req.trim_end_secs = Some(sample_start + sample_dur); sample_req.trim_end_secs = Some(sample_start + sample_dur);
sample_req.deleted_frame_indices.clear(); sample_req.deleted_frame_indices.clear();
sample_req.clicks.clear(); sample_req.clicks.clear();
sample_req.progress_tx = None; sample_req.progress_tx = None;
let result = encode_gif_pass(ffmpeg, &sample_req, est_width, est_fps, 1, 1); if encode_gif_pass(ffmpeg, &sample_req, est_width, est_fps, 1, 1).is_err() {
// 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; return None;
} }
let sample_bytes = match std::fs::metadata(&sample_path) { sample_bytes = std::fs::metadata(&_guard.0).map(|m| m.len()).ok()?;
Ok(m) => m.len(), }
Err(_) => return None,
};
if sample_bytes == 0 { if sample_bytes == 0 {
return None; 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 list_path = parent.join("concat-list.txt");
let _guard = TempFileGuard(list_path.clone()); let _guard = TempFileGuard(list_path.clone());
use std::fmt::Write as _;
let mut body = String::new(); let mut body = String::new();
for seg in segments { for seg in segments {
let s = seg let s = seg
.to_str() .to_str()
.ok_or_else(|| anyhow!("segment path is not UTF-8"))? .ok_or_else(|| anyhow!("segment path is not UTF-8"))?
.replace('\\', "/"); .replace('\\', "/");
use std::fmt::Write as _;
let _ = writeln!(body, "file '{s}'"); let _ = writeln!(body, "file '{s}'");
} }
std::fs::write(&list_path, body).context("writing concat list")?; std::fs::write(&list_path, body).context("writing concat list")?;
+3 -1
View File
@@ -2126,7 +2126,9 @@ pub fn run() {
let cfg = lock(&st.config).clone(); let cfg = lock(&st.config).clone();
(cfg.updates.check_on_launch, cfg) (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::<AppState>(); let st = app.state::<AppState>();
start_overlay_clickthrough_poll( start_overlay_clickthrough_poll(
+2 -2
View File
@@ -186,9 +186,9 @@ fn is_newer(latest: &str, current: &str) -> bool {
} }
match (&l.pre, &c.pre) { match (&l.pre, &c.pre) {
(None, Some(_)) => true, (None, Some(_)) => true,
(Some(_), None) => false,
(Some(a), Some(b)) => a > b, (Some(a), Some(b)) => a > b,
(None, None) => false, // A prerelease never outranks a stable tag of the same version.
(Some(_) | None, None) => false,
} }
} }