From dc033c75a88102962414c3697654dd8c2fd85a27 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 04:10:13 -0500 Subject: fix(recording): create the selected recording directory, not its parent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The recording toggles took a directory from the prefix-arg prompt (or the default), then ran (file-name-directory location) before make-directory. For a path without a trailing slash that returns the parent, so make-directory created the parent and left the selected directory uncreated — ffmpeg then failed to write into it. Both toggles now route the destination through cj/recording--normalize-recording-dir, which expands and applies file-name-as-directory, then call make-directory on that normalized path. The selected directory itself is created (parents=t is a no-op when it already exists), including names with spaces. Tests cover trailing-slash normalization, idempotence, spaces, and relative-to-absolute expansion. --- modules/video-audio-recording.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index b3c4d47b..282fdf85 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -774,6 +774,14 @@ Respects the user's explicit sink choice from quick-setup." ;;; Toggle Commands (User-Facing) ;;; ============================================================ +(defun cj/recording--normalize-recording-dir (location) + "Return LOCATION as an absolute directory path ending in a slash. +The recording target is always a directory ffmpeg writes a timestamped +file into, so normalizing here ensures the *selected* directory is the +one created and recorded into, not its parent (which is what +`file-name-directory' would yield for a path without a trailing slash)." + (file-name-as-directory (expand-file-name location))) + (defun cj/video-recording-toggle (arg) "Toggle video recording: start if not recording, stop if recording. On first use (or when devices not configured), runs quick setup (C-; r s). @@ -782,13 +790,12 @@ Otherwise use the default location in `video-recordings-dir'." (interactive "P") (if cj/video-recording-ffmpeg-process (cj/video-recording-stop) - (let* ((location (if arg - (read-directory-name "Enter recording location: ") - video-recordings-dir)) - (directory (file-name-directory location))) - (unless (file-directory-p directory) - (make-directory directory t)) - (cj/ffmpeg-record-video location)))) + (let ((directory (cj/recording--normalize-recording-dir + (if arg + (read-directory-name "Enter recording location: ") + video-recordings-dir)))) + (make-directory directory t) + (cj/ffmpeg-record-video directory)))) (defun cj/audio-recording-toggle (arg) "Toggle audio recording: start if not recording, stop if recording. @@ -798,13 +805,12 @@ Otherwise use the default location in `audio-recordings-dir'." (interactive "P") (if cj/audio-recording-ffmpeg-process (cj/audio-recording-stop) - (let* ((location (if arg - (read-directory-name "Enter recording location: ") - audio-recordings-dir)) - (directory (file-name-directory location))) - (unless (file-directory-p directory) - (make-directory directory t)) - (cj/ffmpeg-record-audio location)))) + (let ((directory (cj/recording--normalize-recording-dir + (if arg + (read-directory-name "Enter recording location: ") + audio-recordings-dir)))) + (make-directory directory t) + (cj/ffmpeg-record-audio directory)))) ;;; ============================================================ ;;; Start Recording -- cgit v1.2.3