MailCore2中的fetchMessagesByNumberOperationWithFolder并不总是返回最后N个电子邮件数

时间:2015-03-08 09:11:14

标签: ios objective-c mailcore2

在大多数文件夹中,fetchMessagesByNumber按预期工作。如果我希望在一个文件夹中获得最新的40条消息,它将获得大约35-40。我假设我不总是得到40/40的原因是序列号在Gmail(??)中并不总是顺序的。

然而,在我的一个收件箱"所有文件夹"在Gmail中有大约43,000封电子邮件,fetchMessagesByNumber几乎总是不返回任何消息。如果" messagesToGet"是10,100,500,它不会返回任何消息。

直到我尝试检索它返回任何电子邮件的最后3000封邮件。

对于" fetchMessagesByNumber"有什么假设和我做的不正确和我的范围?

MCOIndexSet *numbers = [MCOIndexSet indexSetWithRange:MCORangeMake([info messageCount] - messagesToGet, messagesToGet)];

folderSync = [_imapSession
         fetchMessagesByNumberOperationWithFolder:@"[Gmail]/All Mail"
         requestKind:requestKind
         numbers:numbers];

为了避免这种情况,我使用了另一个查询,但查询UID范围的问题是理论上它更不准确,因为UID不能保证是顺序的。理想情况下,我想使用上述查询,但无法使其正常工作。

MCOIndexSet *numbers = [MCOIndexSet indexSetWithRange:MCORangeMake(lastUID - messagesToGet, messagesToGet)];

folderSync = [_imapSession
         fetchMessagesOperationWithFolder:@"[Gmail]/All Mail"
         requestKind:requestKind
         uids:numbers];

修改

我弄清楚为什么我的方法没有返回预期的#消息。我使用MCOIMAPFolderStatusOperation而不是MCOIMAPFolderInfoOperation。

我认为这两个命令是可以互换的,因为它们都返回[info messageCount]。我选择使用前者来访问status.highestModSeqValue属性。

但是,事实证明,MCOIMAPFolderStatusOperation返回的消息为44514,而MCOIMAPFolderInfoOperation返回的消息为42459。

这是预期的吗?以下是两者的日志。这个是针对MCOIMAPFolderStatusOperation:

2015-03-12 23:02:31.435 iOS UI Test[5529:4648946] checking account
2015-03-12 23:02:31.436 [5529:560f] MCOperationQueue.cpp:81: start thread
2015-03-12 23:02:31.442 [5529:560f] MCIMAPSession.cpp:569: connect <mailcore::IMAPSession:0x7fa043d5d0f0>
2015-03-12 23:02:31.772 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * OK Gimap ready for requests from 98.248.43.119 hl7mb54795112pad
2015-03-12 23:02:31.772 [5529:560f] MCIMAPSession.cpp:592: ssl connect imap.gmail.com 993 2
2015-03-12 23:02:31.774 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 1 CAPABILITY
2015-03-12 23:02:31.823 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
1 OK Thats all she wrote! hl7mb54795112pad
2015-03-12 23:02:31.823 [5529:560f] MCIMAPSession.cpp:649: connect ok
2015-03-12 23:02:31.823 [5529:560f] MCIMAPSession.cpp:689: login
2015-03-12 23:02:31.984 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT
2 OK vu0tran@gmail.com authenticated (Success)
2015-03-12 23:02:31.984 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 3 COMPRESS DEFLATE
2015-03-12 23:02:32.043 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: 3 OK Success
2015-03-12 23:02:32.043 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 4 ENABLE CONDSTORE
2015-03-12 23:02:32.098 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * ENABLED CONDSTORE
4 OK Success
2015-03-12 23:02:32.099 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 5 NAMESPACE
2015-03-12 23:02:32.151 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * NAMESPACE (("" "/")) NIL NIL
5 OK Success
2015-03-12 23:02:32.151 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 6 ID NIL
2015-03-12 23:02:32.208 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * ID ("name" "GImap" "vendor" "Google, Inc." "support-url" "http://support.google.com/mail" "version" "gmail_imap_150308.09_p0" "remote-host" "98.248.43.119")
6 OK Success
2015-03-12 23:02:32.208 [5529:560f] MCIMAPSession.cpp:935: login ok
2015-03-12 23:02:32.208 iOS UI Test[5529:4648946] finished checking account.
2015-03-12 23:02:32.209 [5529:560f] MCIMAPSession.cpp:1063: status
2015-03-12 23:02:32.209 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 7 STATUS "[Gmail]/All Mail" (UNSEEN MESSAGES RECENT UIDNEXT UIDVALIDITY HIGHESTMODSEQ)
2015-03-12 23:02:32.265 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * STATUS "[Gmail]/All Mail" (HIGHESTMODSEQ 4084511 MESSAGES 44514 RECENT 0 UIDNEXT 64049 UIDVALIDITY 612907046 UNSEEN 10719)
7 OK Success
2015-03-12 23:02:32.266 [5529:560f] MCIMAPSession.cpp:1086: status error : 0
2015-03-12 23:02:32.266 [5529:560f] MCIMAPSession.cpp:994: select
2015-03-12 23:02:32.266 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 8 SELECT "[Gmail]/All Mail"
2015-03-12 23:02:32.762 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded JunkRecorded $NotJunk NotJunk $NotPhishing $Junk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded JunkRecorded $NotJunk NotJunk $NotPhishing $Junk \*)] Flags permitted.
* OK [UIDVALIDITY 612907046] UIDs valid.
* 42488 EXISTS
* 0 RECENT
* OK [UIDNEXT 64049] Predicted next UID.
* OK [HIGHESTMODSEQ 4084511]
8 OK [READ-WRITE] [Gmail]/All Mail selected. (Success)
2015-03-12 23:02:32.762 [5529:560f] MCIMAPSession.cpp:998: select error : 0
2015-03-12 23:02:32.762 [5529:560f] MCIMAPSession.cpp:1052: select ok
2015-03-12 23:02:32.762 [5529:560f] MCIMAPSession.cpp:2178: request flags
2015-03-12 23:02:32.763 [5529:560f] MCIMAPSession.cpp:2229: request envelope
2015-03-12 23:02:32.763 [5529:560f] MCIMAPSession.cpp:2251: request bodystructure
2015-03-12 23:02:32.763 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 1 withData: 9 FETCH 44505:44514 (UID FLAGS ENVELOPE BODYSTRUCTURE INTERNALDATE BODY.PEEK[HEADER.FIELDS (References Subject)])
2015-03-12 23:02:32.799 iOS UI Test[5529:4649416] event logged:0x7fa043d58870 0 withData: 9 OK Success
2015-03-12 23:02:32.800 iOS UI Test[5529:4648946] fetched all messages.
2015-03-12 23:02:33.899 [5529:main] MCOperationQueue.cpp:215: trying to quit 0x7fa043d605f0
2015-03-12 23:02:33.899 [5529:560f] MCOperationQueue.cpp:102: stopping 0x7fa043d605f0
2015-03-12 23:02:33.899 [5529:main] MCOperationQueue.cpp:230: thread stopped 0x7fa043d605f0
2015-03-12 23:02:33.899 [5529:560f] MCOperationQueue.cpp:151: cleanup thread 0x7fa043d605f0
2015-03-12 23:03:03.899 [5529:5313] MCOperationQueue.cpp:81: start thread
2015-03-12 23:03:04.980 [5529:main] MCOperationQueue.cpp:215: trying to quit 0x7fa043d605f0
2015-03-12 23:03:04.980 [5529:5313] MCOperationQueue.cpp:102: stopping 0x7fa043d605f0
2015-03-12 23:03:04.981 [5529:main] MCOperationQueue.cpp:230: thread stopped 0x7fa043d605f0
2015-03-12 23:03:04.981 [5529:5313] MCOperationQueue.cpp:151: cleanup thread 0x7fa043d605f0

这个是针对MCOIMAPFolderInfoOperation:

2015-03-12 23:09:11.390 iOS UI Test[8138:4681733] checking account
2015-03-12 23:09:11.391 [8138:560f] MCOperationQueue.cpp:81: start thread
2015-03-12 23:09:11.396 [8138:560f] MCIMAPSession.cpp:569: connect <mailcore::IMAPSession:0x7fcfb31218d0>
2015-03-12 23:09:11.767 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * OK Gimap ready for requests from 98.248.43.119 cm1mb31383387pbc
2015-03-12 23:09:11.767 [8138:560f] MCIMAPSession.cpp:592: ssl connect imap.gmail.com 993 2
2015-03-12 23:09:11.769 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 1 CAPABILITY
2015-03-12 23:09:11.824 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
1 OK Thats all she wrote! cm1mb31383387pbc
2015-03-12 23:09:11.824 [8138:560f] MCIMAPSession.cpp:649: connect ok
2015-03-12 23:09:11.824 [8138:560f] MCIMAPSession.cpp:689: login
2015-03-12 23:09:11.907 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT
2 OK vu0tran@gmail.com authenticated (Success)
2015-03-12 23:09:11.907 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 3 COMPRESS DEFLATE
2015-03-12 23:09:11.959 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: 3 OK Success
2015-03-12 23:09:11.960 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 4 ENABLE CONDSTORE
2015-03-12 23:09:12.012 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * ENABLED CONDSTORE
4 OK Success
2015-03-12 23:09:12.013 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 5 NAMESPACE
2015-03-12 23:09:12.069 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * NAMESPACE (("" "/")) NIL NIL
5 OK Success
2015-03-12 23:09:12.070 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 6 ID NIL
2015-03-12 23:09:12.123 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * ID ("name" "GImap" "vendor" "Google, Inc." "support-url" "http://support.google.com/mail" "version" "gmail_imap_150308.09_p0" "remote-host" "98.248.43.119
2015-03-12 23:09:12.124 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: ")
6 OK Success
2015-03-12 23:09:12.124 [8138:560f] MCIMAPSession.cpp:935: login ok
2015-03-12 23:09:12.124 iOS UI Test[8138:4681733] finished checking account.
2015-03-12 23:09:12.124 [8138:560f] MCIMAPSession.cpp:994: select
2015-03-12 23:09:12.124 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 7 SELECT "[Gmail]/All Mail"
2015-03-12 23:09:12.620 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 0 withData: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded JunkRecorded $NotJunk NotJunk $NotPhishing $Junk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded JunkRecorded $NotJunk NotJunk $NotPhishing $Junk \*)] Flags permitted.
* OK [UIDVALIDITY 612907046] UIDs valid.
* 42488 EXISTS
* 0 RECENT
* OK [UIDNEXT 64049] Predicted next UID.
* OK [HIGHESTMODSEQ 4084511]
7 OK [READ-WRITE] [Gmail]/All Mail selected. (Success)
2015-03-12 23:09:12.620 [8138:560f] MCIMAPSession.cpp:998: select error : 0
2015-03-12 23:09:12.620 [8138:560f] MCIMAPSession.cpp:1052: select ok
2015-03-12 23:09:12.621 [8138:560f] MCIMAPSession.cpp:2178: request flags
2015-03-12 23:09:12.621 [8138:560f] MCIMAPSession.cpp:2229: request envelope
2015-03-12 23:09:12.621 [8138:560f] MCIMAPSession.cpp:2251: request bodystructure
2015-03-12 23:09:12.621 iOS UI Test[8138:4682226] event logged:0x7fcfb311d980 1 withData: 8 FETCH 42479:42488 (UID FLAGS ENVELOPE BODYSTRUCTURE INTERNALDATE BODY.PEEK[HEADER.FIELDS (References Subject)])

0 个答案:

没有答案