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

fix application stucking at main.go:127 cReader.Select() #1

Closed aheissenberger closed 3 years ago

aheissenberger commented 3 years ago

when mailbox list was not consumed in lib/mailboxes.go function DetectTrash by leaving the loop with a return, the main app was hanging when trying to request the mailbox in main.go:127 cReader.Select()

Was really hard to find ;-) for a total Golang novice like me. Thanks for the great app! Andreas

axllent commented 3 years ago

So what you are saying is that if there is no trash folder in IMAP, then the app will hang because the channel is left open? I can't believe I have never picked this up, although every IMAP I've used has a trash folder so I wouldn't have detected this I think.

Wow, good catch, thanks for contributing! If you're a Go novice then you're doing pretty well :) I'll release a new version soon.

aheissenberger commented 3 years ago

So what you are saying is that if there is no trash folder in IMAP, then the app will hang because the channel is left open?

No - it always detected the right trash folder on Gmail and then later when it tried to select a mailbox the app stuck. Based on my rudimentary knowhow of go it has to do with the channels not being consumed and closed.

I tried a lot of things like upgrading dependencies, running in a linux container instead of running directly on MacOS. When I tested the code from the go-imap repo and it worked I started to remove all code before the Select() and after replacing the code for trash detection with a static value everything worked.

I have debugged so many applications in the last 40 years that after setting up a proper debugging setup I usually find the problem regardless of the programming language :-)