diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp index c0f8501e99..aa2139b7e2 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp @@ -318,16 +318,18 @@ FetchMessageCommand::FetchMessageCommand(IMAPMailbox& mailbox, fMessage(firstMessage), fEndMessage(lastMessage), fOutData(NULL), - fFetchBodyLimit(fetchBodyLimit), - fHandled(false) + fFetchBodyLimit(fetchBodyLimit) { - + if (fEndMessage > 0) + fUnhandled = fEndMessage - fMessage + 1; + else + fUnhandled = 1; } FetchMessageCommand::~FetchMessageCommand() { - if (!fHandled) + for (int32 i = 0; i < fUnhandled; i++) fIMAPMailbox.Listener().FetchEnd(); } @@ -409,7 +411,7 @@ FetchMessageCommand::Handle(const BString& response) BString lastLine; fConnectionReader.GetNextLine(lastLine); - fHandled = true; + fUnhandled--; bool bodyIsComing = true; if (fFetchBodyLimit >= 0 && fFetchBodyLimit <= messageSize) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h index d9f7bb8986..031db60ceb 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.h @@ -140,7 +140,7 @@ private: int32 fEndMessage; BPositionIO* fOutData; int32 fFetchBodyLimit; - bool fHandled; + int32 fUnhandled; };