case-insensitive extensions and explicit else arms
This commit is contained in:
@@ -337,6 +337,8 @@ fn find_ffmpeg_in(dir: &Path) -> Option<PathBuf> {
|
|||||||
return Some(p);
|
return Some(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Anything else is neither a directory nor a named file, so there is
|
||||||
|
// nothing to look at inside it.
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-13
@@ -994,7 +994,12 @@ fn clean_stale_palettes(dir: &Path) {
|
|||||||
if let Ok(entries) = std::fs::read_dir(dir) {
|
if let Ok(entries) = std::fs::read_dir(dir) {
|
||||||
for entry in entries.flatten() {
|
for entry in entries.flatten() {
|
||||||
if let Some(name) = entry.file_name().to_str() {
|
if let Some(name) = entry.file_name().to_str() {
|
||||||
if name.starts_with("preview-palette-") && name.ends_with(".png") {
|
// Case-insensitive for the same reason as the temp sweep: these
|
||||||
|
// are the app's own files, but Windows keeps the case it was given.
|
||||||
|
let is_png = Path::new(name)
|
||||||
|
.extension()
|
||||||
|
.is_some_and(|e| e.eq_ignore_ascii_case("png"));
|
||||||
|
if name.starts_with("preview-palette-") && is_png {
|
||||||
drop(std::fs::remove_file(entry.path()));
|
drop(std::fs::remove_file(entry.path()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1249,19 +1254,23 @@ fn run_impl(
|
|||||||
let mut last_out_time_us: f64 = 0.0;
|
let mut last_out_time_us: f64 = 0.0;
|
||||||
for line in reader.lines().map_while(Result::ok) {
|
for line in reader.lines().map_while(Result::ok) {
|
||||||
if let Some((key, value)) = parse_progress_kv(&line) {
|
if let Some((key, value)) = parse_progress_kv(&line) {
|
||||||
if key == "out_time_us" {
|
match key {
|
||||||
last_out_time_us = value;
|
"out_time_us" => last_out_time_us = value,
|
||||||
} else if key == "progress" {
|
"progress" => {
|
||||||
let percent = (last_out_time_us / encode_dur_us * 100.0).clamp(0.0, 100.0);
|
let percent =
|
||||||
if let Some(ref sender) = tx {
|
(last_out_time_us / encode_dur_us * 100.0).clamp(0.0, 100.0);
|
||||||
// A dropped receiver means the frontend is gone;
|
if let Some(ref sender) = tx {
|
||||||
// the encode keeps running either way.
|
// A dropped receiver means the frontend is gone;
|
||||||
let _ = sender.send(EncodeProgress {
|
// the encode keeps running either way.
|
||||||
pass,
|
let _ = sender.send(EncodeProgress {
|
||||||
total_passes,
|
pass,
|
||||||
percent,
|
total_passes,
|
||||||
});
|
percent,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// frame=, fps=, bitrate= and friends are not needed.
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-14
@@ -333,15 +333,26 @@ fn audio_segment_path(app_dir: &Path, idx: usize) -> PathBuf {
|
|||||||
/// raw-preview.png from the previous clip, and deleting them under it made the
|
/// raw-preview.png from the previous clip, and deleting them under it made the
|
||||||
/// asset protocol log "file does not exist" and briefly broke the preview.
|
/// asset protocol log "file does not exist" and briefly broke the preview.
|
||||||
/// Startup and exit sweep everything.
|
/// Startup and exit sweep everything.
|
||||||
|
/// Case-insensitive extension test, for the temp sweeps: Windows file names are
|
||||||
|
/// case-preserving, so `ends_with(".mp4")` would miss `SEGMENT-001.MP4`.
|
||||||
|
fn has_ext(name: &str, ext: &str) -> bool {
|
||||||
|
Path::new(name)
|
||||||
|
.extension()
|
||||||
|
.is_some_and(|e| e.eq_ignore_ascii_case(ext))
|
||||||
|
}
|
||||||
|
|
||||||
fn clear_temp_segments(app_dir: &Path, keep_previews: bool) {
|
fn clear_temp_segments(app_dir: &Path, keep_previews: bool) {
|
||||||
let temp = temp_dir(app_dir);
|
let temp = temp_dir(app_dir);
|
||||||
if let Ok(entries) = std::fs::read_dir(&temp) {
|
if let Ok(entries) = std::fs::read_dir(&temp) {
|
||||||
for entry in entries.flatten() {
|
for entry in entries.flatten() {
|
||||||
if let Some(name) = entry.file_name().to_str() {
|
if let Some(name) = entry.file_name().to_str() {
|
||||||
if (name.starts_with("segment-") && name.ends_with(".mp4"))
|
// The padtmp files carry a double extension, so they are matched
|
||||||
|| (name.starts_with("audio-") && name.ends_with(".pcm"))
|
// on the whole name rather than through Path::extension.
|
||||||
|| name.ends_with(".pcm.padtmp")
|
let padtmp = name.to_ascii_lowercase().ends_with(".pcm.padtmp");
|
||||||
|| (name.starts_with("preview-palette-") && name.ends_with(".png"))
|
if (name.starts_with("segment-") && has_ext(name, "mp4"))
|
||||||
|
|| (name.starts_with("audio-") && has_ext(name, "pcm"))
|
||||||
|
|| (name.starts_with("preview-palette-") && has_ext(name, "png"))
|
||||||
|
|| padtmp
|
||||||
{
|
{
|
||||||
drop(std::fs::remove_file(entry.path()));
|
drop(std::fs::remove_file(entry.path()));
|
||||||
}
|
}
|
||||||
@@ -843,6 +854,9 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
|
|||||||
.or_else(|_| std::fs::copy(&video_concat, &final_path).map(|_| ()))
|
.or_else(|_| std::fs::copy(&video_concat, &final_path).map(|_| ()))
|
||||||
.map_err(|e| format!("finalizing: {e:#}"))?;
|
.map_err(|e| format!("finalizing: {e:#}"))?;
|
||||||
drop(std::fs::remove_file(&video_concat));
|
drop(std::fs::remove_file(&video_concat));
|
||||||
|
} else {
|
||||||
|
// No audio and a single segment: the concat output already sits at
|
||||||
|
// final_path, so there is nothing left to move.
|
||||||
}
|
}
|
||||||
|
|
||||||
let clip = RecordedClip {
|
let clip = RecordedClip {
|
||||||
@@ -1226,14 +1240,10 @@ fn start_overlay_clickthrough_poll(
|
|||||||
if unsafe { GetCursorPos(&raw mut pt) }.is_err() {
|
if unsafe { GetCursorPos(&raw mut pt) }.is_err() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let raw = match overlay.hwnd() {
|
let Ok(raw) = overlay.hwnd() else { continue };
|
||||||
Ok(h) => h,
|
|
||||||
Err(_) => continue,
|
|
||||||
};
|
|
||||||
|
|
||||||
let (vl, vt, vr, vb) = match visible_window_bounds(raw.0 as isize) {
|
let Some((vl, vt, vr, vb)) = visible_window_bounds(raw.0 as isize) else {
|
||||||
Some(b) => b,
|
continue;
|
||||||
None => continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// SAFETY: `raw` is the overlay's own live HWND from Tauri.
|
// SAFETY: `raw` is the overlay's own live HWND from Tauri.
|
||||||
@@ -1405,9 +1415,8 @@ fn enforce_overlay_aspect(app: AppHandle, state: State<'_, AppState>) -> Result<
|
|||||||
use windows::Win32::Foundation::HWND;
|
use windows::Win32::Foundation::HWND;
|
||||||
use windows::Win32::UI::WindowsAndMessaging::{SetWindowPos, HWND_TOP, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOZORDER};
|
use windows::Win32::UI::WindowsAndMessaging::{SetWindowPos, HWND_TOP, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOZORDER};
|
||||||
|
|
||||||
let ratio = match *lock(&state.overlay_aspect_ratio) {
|
let Some(ratio) = *lock(&state.overlay_aspect_ratio) else {
|
||||||
Some(r) => r,
|
return Ok(());
|
||||||
None => return Ok(()),
|
|
||||||
};
|
};
|
||||||
let win = app
|
let win = app
|
||||||
.get_webview_window("overlay")
|
.get_webview_window("overlay")
|
||||||
|
|||||||
@@ -137,9 +137,8 @@ unsafe extern "system" fn enum_at_point(hwnd: HWND, lparam: LPARAM) -> BOOL {
|
|||||||
return BOOL(1);
|
return BOOL(1);
|
||||||
}
|
}
|
||||||
// SAFETY: `hwnd` is the live handle described above.
|
// SAFETY: `hwnd` is the live handle described above.
|
||||||
let rect = match unsafe { visible_window_rect(hwnd) } {
|
let Some(rect) = (unsafe { visible_window_rect(hwnd) }) else {
|
||||||
Some(r) => r,
|
return BOOL(1);
|
||||||
None => return BOOL(1),
|
|
||||||
};
|
};
|
||||||
if ctx.point.x < rect.left
|
if ctx.point.x < rect.left
|
||||||
|| ctx.point.x >= rect.right
|
|| ctx.point.x >= rect.right
|
||||||
@@ -223,6 +222,8 @@ pub(crate) fn start(app: AppHandle, exclude_hwnds: Vec<isize>) -> PickerSession
|
|||||||
} else if last_hwnd != 0 {
|
} else if last_hwnd != 0 {
|
||||||
tracing::info!("picker hover: no target found at ({}, {})", pt.x, pt.y);
|
tracing::info!("picker hover: no target found at ({}, {})", pt.x, pt.y);
|
||||||
last_hwnd = 0;
|
last_hwnd = 0;
|
||||||
|
} else {
|
||||||
|
// Still hovering the same window, so the frame is already drawn.
|
||||||
}
|
}
|
||||||
|
|
||||||
let pressed =
|
let pressed =
|
||||||
|
|||||||
Reference in New Issue
Block a user