diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2021-08-21 16:29:31 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-21 16:29:31 +0300 |
| commit | 5a6fcab31d08093bd17882d4a426ef1fecd8bc0c (patch) | |
| tree | 2f96d6d4e6e000f6140f2280a75bb94862a97547 | |
| parent | 06989768f49bb623f65003db406343d92e01de50 (diff) | |
| parent | 372726cb9ed7e86cc4cb38268e44a3923dd8010c (diff) | |
Merge pull request #2093 from thierryvolpiatto/fix_dups_when_saving_attachments
Create numbered backup of attached file when already exists #2090
| -rw-r--r-- | mu4e/mu4e-view-gnus.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mu4e/mu4e-view-gnus.el b/mu4e/mu4e-view-gnus.el index 8ad45d6..21332ad 100644 --- a/mu4e/mu4e-view-gnus.el +++ b/mu4e/mu4e-view-gnus.el @@ -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")))) |
