axllent / imap-scrub

A ultility to trim down your IMAP mailbox by saving & removing attachments or deleting messages based on rules
MIT License
20 stars 5 forks source link

write full output paths of saved attachments into "%d-attachments-deleted.txt" #8

Closed michalfapso closed 5 months ago

michalfapso commented 5 months ago

Hi and thanks for this project!

I thought it could be more convenient to write the whole output path (including the hash) of the saved attachment into the txt file which replaces the original attachments in an email. It could be easier to find the saved attachment file this way.

I just modified SaveAttachment() to return also the output path which is then put into the DeletedAttachment struct instead of the original filename

axllent commented 5 months ago

Thanks for your contribution @michalfapso. I believe there's a couple of flaws in your logic as it always assumes you are saving the attachment: deleted = append(deleted, DeletedAttachment{filename_out, ct, size}) - where filename_out is only set based on the output filename of the locally-saved attachment. If one does not save the attachment (ie: just delete) then this variable remains blank, and so won't get properly included in the attachment body (x.attachments-deleted.txt).

Also your adjustments to attachmentText assume the files are saved locally where they could have just been deleted. Could you please adjust your patch to cater for both when someone saves attachments as well as not? Thanks!

michalfapso commented 5 months ago

Thanks, @axllent! That's indeed a good point. I used it only with actions: save_attachments, remove_attachments and then I forgot they can be used separately as well.

I've adjusted the code according to your comments and rebased it so it's still just a single commit.

axllent commented 5 months ago

Thanks. I have merged this in and released a new version.

Please could you also take a look at #10 and let me know if you are interested?

michalfapso commented 5 months ago

Thanks for your offer, @axllent, but I have very little spare time as well. I've just subscribed to "All Activity" notifications of your project and I'll try to look at the issues. I haven't used Go until now and I'm still not familiar enough with your code, so I'd still need your feedback on my potential merge requests :)

axllent commented 5 months ago

That's no problem, I just thought I'd ask in case you were interested. This project does not get enough love, but to do that it actually needs to be rewritten which takes time. It was originally hacked together to do a specific task, and all subsequent features were just added into the code (but the code structure doesn't really suit it).