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

include_unread is confusing #5

Closed jgonera closed 1 year ago

jgonera commented 1 year ago

Hey, thank you for a great tool! I really like how it's putting a text file in modified emails with file names of the attachments it's removing.

I added include_unread: true and to my surprise the output changed from:

Searching "[Gmail]/All Mail" for unread, unstarred, larger: 100.0kB

to:

Searching "[Gmail]/All Mail" for unstarred, larger: 100.0kB

Should include_unread be actually called exclude_unread or is the output message wrong?

axllent commented 1 year ago

@jgonera I'm glad you find the tool handy (it has saved me many gigs of "useless" data) :) Maybe it is my own (lack of?) logic here, or maybe I am just misunderstanding the point you are trying to make - but by default imap-scrub will exclude unread and starred messages in the "scrub".

When you add include_unread, imap-scrub will search for both unread and read messages in the cleanup, so it's not displayed in the output as it's not filtering by that status.

Did I miss the point you were trying to make?

jgonera commented 1 year ago

Sorry, maybe I didn't explain this well.

Let's assume I have a config like this:

rules:
  - mailbox: "[Gmail]/All Mail"
    min_size: 256
    actions: save_attachments

Then, when I run imap-scrub, the output I get is:

Connecting to imap.gmail.com:993...
Deleted messages will be moved to "[Gmail]/Trash"
Searching "[Gmail]/All Mail" for unread, unstarred, larger: 256.0kB

As you can see, my config does not have include_unread so it should default to false. Yet, the output says that we are searching for unread messages.

Now, let's say my config looks like this:

rules:
  - mailbox: "[Gmail]/All Mail"
    min_size: 256
    include_unread: true
    actions: save_attachments

Now it does have include_unread: true. The output when running imap-scrub now looks like this though:

Connecting to imap.gmail.com:993...
Deleted messages will be moved to "[Gmail]/Trash"
Searching "[Gmail]/All Mail" for unstarred, larger: 256.0kB

As you can see, it does not say anymore "Searching "[Gmail]/All Mail" for unread" despite include_unread: true.

I'm not sure if it's only the logging that's wrong and the underlying behavior is correct, or include_unread actually does the opposite of what it should.

The logging for include_starred is actually correct, so that was a false alarm.

axllent commented 1 year ago

@jgonera I see what you mean, and you are absolutely correct.

Searching "[Gmail]/All Mail" for unread, unstarred, larger: 256.0kB

should say

Searching "[Gmail]/All Mail" for read, unstarred, larger: 256.0kB

This is a cosmetic change, so simply the output you see. I've checked the logic, and when include_unread: false (or not set, ie: the default) the IMAP search filter \\Seen is applied correctly (limiting results to read messages only).

If include_unread: true the output in your example should just say:

Searching "[Gmail]/All Mail" for unstarred, larger: 256.0kB

I'll make this change today and release a new version for you :+1:

axllent commented 1 year ago

This has been released now with 0.0.4. Please let me know if this resolved your issue? Thanks.

jgonera commented 1 year ago

Yes, perfect. It's more reassuring with the correct output :) Thank you!