From 469974fa74e1661ea0a60cb5249ee0d3c6f640fd Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 17 Dec 2021 13:10:42 +0100 Subject: ensure media-attachment is not a dir --- lisp/mastodon-toot.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 71bd3ad..2ff7f83 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -632,15 +632,17 @@ File is actually attached to the toot upon posting." (when (>= (length mastodon-toot--media-attachments) 4) ;; Only a max. of 4 attachments are allowed, so pop the oldest one. (pop mastodon-toot--media-attachments)) - (setq mastodon-toot--media-attachments - (nconc mastodon-toot--media-attachments - `(((:contents . ,(mastodon-http--read-file-as-string file)) - (:content-type . ,content-type) - (:description . ,description) - (:filename . ,file))))) - (mastodon-toot--refresh-attachments-display) - ;; upload only most recent attachment: - (mastodon-toot--upload-attached-media (car (last mastodon-toot--media-attachments)))) + (if (file-directory-p file) + (message "Looks like you chose a directory not a file.") + (setq mastodon-toot--media-attachments + (nconc mastodon-toot--media-attachments + `(((:contents . ,(mastodon-http--read-file-as-string file)) + (:content-type . ,content-type) + (:description . ,description) + (:filename . ,file))))) + (mastodon-toot--refresh-attachments-display) + ;; upload only most recent attachment: + (mastodon-toot--upload-attached-media (car (last mastodon-toot--media-attachments))))) (defun mastodon-toot--upload-attached-media (attachment) "Upload a single attachment using `mastodon-http--post-media-attachment'. -- cgit v1.2.3