aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@postbox.nz>2023-06-07 14:27:13 +0300
committerRobin Jarry <robin@jarry.cc>2023-06-10 19:58:14 +0200
commit5fc6c8408450a8a7e7b6d33632155d6aca0db9be (patch)
treef8430210630e2233b80b7a6f45d89d5c9033f3d8 /commands
parentedd4752268b266d697be51733599b708e4ae449a (diff)
downloadaerc-5fc6c8408450a8a7e7b6d33632155d6aca0db9be.tar.gz
save: new option for saving attachments
Add a new `-A` option to `:save` that works in the same manner as `-a`, but saves all the named parts of an email, not just attachments. The reason is that I have an email with this structure: multipart/related multipart/alternative text/plain text/html image/png (image001.png) image/png (image002.png) image/png (image003.png) text/plain (env.txt) Where the `env.txt` is a "real" attachment, while the images are just a part of the HTML version of the email. However, in this particular email it was important to see them which can't be done with text UI and opening the HTML part with the browser also didn't work. Saving them to a temorary folder did the job and this can be useful in other scenarios. So before the patch we could do `:save -ap /some/path` and get just the `env.txt` saved there. After the patch we could also do `:save -Ap /some/path` and get all the images and the text file saved into the folder. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands')
-rw-r--r--commands/msgview/save.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 7d82ff95..5bd4c188 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -26,7 +26,7 @@ func init() {
}
func (Save) Options() string {
- return "fpa"
+ return "fpaA"
}
func (Save) Aliases() []string {
@@ -45,10 +45,11 @@ func (s Save) Complete(aerc *widgets.Aerc, args []string) []string {
}
type saveParams struct {
- force bool
- createDirs bool
- trailingSlash bool
- attachments bool
+ force bool
+ createDirs bool
+ trailingSlash bool
+ attachments bool
+ allAttachments bool
}
func (s Save) Execute(aerc *widgets.Aerc, args []string) error {
@@ -67,6 +68,8 @@ func (s Save) Execute(aerc *widgets.Aerc, args []string) error {
params.createDirs = true
case 'a':
params.attachments = true
+ case 'A':
+ params.allAttachments = true
}
}
@@ -106,8 +109,8 @@ func (s Save) Execute(aerc *widgets.Aerc, args []string) error {
return fmt.Errorf("SelectedTabContent is not a MessageViewer")
}
- if params.attachments {
- parts := mv.AttachmentParts()
+ if params.attachments || params.allAttachments {
+ parts := mv.AttachmentParts(params.allAttachments)
if len(parts) == 0 {
return fmt.Errorf("This message has no attachments")
}