snipsco / Postal

A Swift framework for working with emails
MIT License
652 stars 81 forks source link

fetchMessages attempts to fetch 1 additional message (fetchLast fails with .undefined) #44

Closed matadan closed 7 years ago

matadan commented 7 years ago

It appears that giving an IndexSet to fetchMessages() with a single index actually tries to fetch 2 messages. This also means that fetchLast() fails.

i.e.

   let indexset = IndexSet(integer: 2750)
   postal.fetchMessages("INBOX", uids: indexset, flags: [ .fullHeaders ], ...

actually tries to fetch messages 2750 and 2751.

klefevre commented 7 years ago

Interesting... thank for the report. Could you you just tell me which mail provider you are on ?

matadan commented 7 years ago

I'm testing with iCloud.

matadan commented 7 years ago

I think it might be because IndexSet.unreleasedMailimapSet() includes the upperBound in the Range but the range is 2750..<2751 so should not include the upperBound.

Could it be that it does not know the difference between 1...2 and 1..<2 ranges?

matadan commented 7 years ago

I think that fixed it. I'll submit a PR.

klefevre commented 7 years ago

You're right the conversion between IndexSet and mailimap_set is wrong.

matadan commented 7 years ago

I have submitted a PR.