diff options
author | mousebot <mousebot@riseup.net> | 2021-12-17 13:10:42 +0100 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-12-17 13:10:42 +0100 |
commit | 469974fa74e1661ea0a60cb5249ee0d3c6f640fd (patch) | |
tree | 0ebf6a5d9b6678418b791b7a24fb2cd96f7b2db5 | |
parent | 7721f592731f1cdb8d4f36311dd9675580eb846b (diff) |
ensure media-attachment is not a dir
-rw-r--r-- | lisp/mastodon-toot.el | 20 |
1 files 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'. |