From 8b7617c5aeb720a94f79ccc7201fd5ee042a5635 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 9 May 2020 23:37:47 -0400 Subject: b4: Rework handling of output file naming When passing a name like "a.mbx" to b4-am's --mbox-name, only the "a" is retained; b4-am unconditionally appends the ".mbx". Avoid passing a name with ".mbx" to make it clearer that the caller does not control the extension. Reduce the base name to "m" to avoid a message ID ending with ".*" being treated as an extension, which would require analyzing the message ID in order to guess what output name b4-am will use. Finally, name the custom thread mbox with "-piem" rather than "-thread" (which was chosen to mimic b4-mbox) so it's more obvious who created the file when later inspecting the directory. --- piem-b4.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/piem-b4.el b/piem-b4.el index e085848..bbd7cb2 100644 --- a/piem-b4.el +++ b/piem-b4.el @@ -83,11 +83,10 @@ ;; default to using that, but it should still be an option to use b4 ;; so that we honor its customization/URL resolution. (defun piem-b4--get-mbox-file (mid coderepo args) - (let* ((mbox-name (format "%s.mbx" mid)) - (outdir (file-name-as-directory + (let* ((outdir (file-name-as-directory (make-temp-file "piem-b4-" t))) - (mbox-am (concat outdir mbox-name)) - (mbox-thread (concat mbox-am "-thread")) + (root (concat outdir "m")) + (mbox-thread (concat root "-piem")) (custom-p nil)) (when-let ((fn (run-hook-with-args-until-success 'piem-mid-to-thread-functions mid))) @@ -102,11 +101,12 @@ (and custom-p (concat "--use-local-mbox=" mbox-thread)) (concat "--outdir=" outdir) - (concat "--mbox-name=" mbox-name) + (concat "--mbox-name=m") (append args (list mid)))) - (unless (file-exists-p mbox-am) - (error "Expected mbox file does not exist: %s" mbox-am)) - mbox-am)) + (let ((mbox-am (concat root ".mbx"))) + (if (file-exists-p mbox-am) + mbox-am + (error "Expected mbox file does not exist: %s" mbox-am))))) ;;; Commands -- cgit v1.2.3