mirror of https://github.com/djcb/mu.git
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:
commit
5a6fcab31d
|
@ -500,7 +500,20 @@ containing commas."
|
||||||
dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir))
|
dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir))
|
||||||
(cl-loop for (f . h) in handles
|
(cl-loop for (f . h) in handles
|
||||||
when (member f files)
|
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"))))
|
(mu4e-message "No attached files found"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue