Merge pull request #2093 from thierryvolpiatto/fix_dups_when_saving_attachments

Create numbered backup of attached file when already exists #2090
This commit is contained in:
Dirk-Jan C. Binnema 2021-08-21 16:29:31 +03:00 committed by GitHub
commit 5a6fcab31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -500,7 +500,20 @@ containing commas."
dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir))
(cl-loop for (f . h) in handles
when (member f files)
do (mm-save-part h (expand-file-name f dir))))
do (mm-save-part-to-file
h (let ((file (expand-file-name f dir)))
(if (file-exists-p file)
(let (newname (count 1))
(while (and
(setq newname
(concat
(file-name-sans-extension file)
(format "(%s)" count)
(file-name-extension file t)))
(file-exists-p newname))
(cl-incf count))
newname)
file)))))
(mu4e-message "No attached files found"))))