tidy bindings, closures and string building

This commit is contained in:
2026-09-21 01:31:16 +03:00
parent c7a4721e7d
commit 3f50fdd337
3 changed files with 14 additions and 10 deletions
+2 -2
View File
@@ -171,8 +171,8 @@ async fn fetch_sha256(client: &reqwest::Client, url: &str) -> Result<[u8; 32]> {
if line.len() < 64 {
return None;
}
let (hash, _file) = line.split_at(64);
let remainder = _file.trim_start();
let (hash, file) = line.split_at(64);
let remainder = file.trim_start();
// Must be followed by two spaces and a filename
if !remainder.starts_with(" ") {
return None;
+4 -2
View File
@@ -1089,7 +1089,8 @@ pub(crate) fn concat_pcm(segments: &[PathBuf], output: &Path) -> Result<()> {
}
let mut out = std::fs::File::create(output).context("creating audio concat file")?;
for seg in segments {
let mut f = std::fs::File::open(seg).with_context(|| format!("opening {seg:?}"))?;
let mut f = std::fs::File::open(seg)
.with_context(|| format!("opening {}", seg.display()))?;
std::io::copy(&mut f, &mut out).context("copying audio segment")?;
}
out.flush()?;
@@ -1123,7 +1124,8 @@ pub(crate) fn concat_segments(ffmpeg: &Path, segments: &[PathBuf], output: &Path
.to_str()
.ok_or_else(|| anyhow!("segment path is not UTF-8"))?
.replace('\\', "/");
body.push_str(&format!("file '{s}'\n"));
use std::fmt::Write as _;
let _ = writeln!(body, "file '{s}'");
}
std::fs::write(&list_path, body).context("writing concat list")?;
+8 -6
View File
@@ -391,7 +391,8 @@ fn adjust_audio_length(path: &Path, sample_rate: u32, channels: u16, target_secs
let to_write = usize::try_from(remaining.min(chunk))
.unwrap_or(zeros.len())
.min(zeros.len());
file.write_all(&zeros[..to_write])?;
// to_write was clamped to zeros.len() just above.
file.write_all(zeros.get(..to_write).unwrap_or_default())?;
remaining -= u64::try_from(to_write).unwrap_or(0);
}
} else {
@@ -428,7 +429,8 @@ fn pad_audio_head(path: &Path, sample_rate: u32, channels: u16, head_secs: f64)
let to_write = usize::try_from(remaining.min(chunk))
.unwrap_or(zeros.len())
.min(zeros.len());
out.write_all(&zeros[..to_write])?;
// to_write was clamped to zeros.len() just above.
out.write_all(zeros.get(..to_write).unwrap_or_default())?;
remaining -= u64::try_from(to_write).unwrap_or(0);
}
out.flush()?;
@@ -617,7 +619,7 @@ fn pause_capture(state: State<'_, AppState>) -> Result<(), String> {
.map_err(|e| format!("fixing fps: {e:#}"))?;
let path = if fixed_path.exists() { fixed_path } else { raw_path };
let audio_path = lock(&state.audio).take().map(|a| a.stop());
let audio_path = lock(&state.audio).take().map(audio::AudioSession::stop);
let new_clicks: Vec<clicks::Click> = lock(&state.click_recorder)
.take()
@@ -2197,12 +2199,12 @@ pub fn run() {
])
.build(tauri::generate_context!())
.expect("error while building ByteSize");
app.run(|_app: &AppHandle, event| {
app.run(|app, event| {
if let tauri::RunEvent::Exit = event {
if let Some(st) = _app.try_state::<AppState>() {
if let Some(st) = app.try_state::<AppState>() {
st.overlay_poll_shutdown.store(true, Ordering::SeqCst);
}
cleanup_temp_on_exit(_app);
cleanup_temp_on_exit(app);
}
});
}