merge duplicate arms and drop a needless clone
This commit is contained in:
+21
-20
@@ -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);
|
||||||
|
|
||||||
// Build a throwaway request scoped to the sample window.
|
// Defer cleanup until we've measured the sample: the guard owns a copy of
|
||||||
let mut sample_req = req.clone();
|
// the path, which lets the original move into the request below. Earlier
|
||||||
sample_req.output = sample_path.clone();
|
// versions removed the file here, which made the metadata read always fail
|
||||||
sample_req.trim_start_secs = Some(sample_start);
|
// and the whole calibration path silently no-op.
|
||||||
sample_req.trim_end_secs = Some(sample_start + sample_dur);
|
let sample_bytes;
|
||||||
sample_req.deleted_frame_indices.clear();
|
{
|
||||||
sample_req.clicks.clear();
|
let _guard = TempFileGuard(sample_path.clone());
|
||||||
sample_req.progress_tx = None;
|
|
||||||
|
|
||||||
let result = encode_gif_pass(ffmpeg, &sample_req, est_width, est_fps, 1, 1);
|
// Build a throwaway request scoped to the sample window.
|
||||||
// Defer cleanup until we've measured the sample. Earlier versions removed
|
let mut sample_req = req.clone();
|
||||||
// the file here, which made the metadata read below always fail and the
|
sample_req.output = sample_path;
|
||||||
// whole calibration path silently no-op.
|
sample_req.trim_start_secs = Some(sample_start);
|
||||||
let _guard = TempFileGuard(sample_path.clone());
|
sample_req.trim_end_secs = Some(sample_start + sample_dur);
|
||||||
if result.is_err() {
|
sample_req.deleted_frame_indices.clear();
|
||||||
return None;
|
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 {
|
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")?;
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user