IMAP UID 的可靠性如何?
我正在编写一个 IMAP 爬网程序,它是开源应用程序的一部分,对于增量爬网,我想使用消息 UID 来查明我是否已经看到特定消息。
现在我发现一篇2007年的帖子说IMAP UID 并不总是可靠的。更具体地说,如果设置了 UIDNOTSTICKY 标志,则不能假设 UID 始终相同。 所以我的问题是,我是否必须认真对待 UIDNOTSTICKY=true 的情况,或者 IMAP 服务器是否具有非粘性 UID 遗留内容并且不再(广泛)使用?
I'm writing an IMAP crawler, which is part of an Open Source app, and for incremental crawling I'd like to use the message UIDs to find out whether I've already seen a particular message or not.
Now I found a post from 2007 that says IMAP UIDs aren't always reliable. More specifically, if the flag UIDNOTSTICKY is set, you can't assume the UIDs are always the same.
So my question is, do I have to take the case UIDNOTSTICKY=true seriously, or are IMAP servers with non-sticky UIDs legacy stuff and not in (widespread) use anymore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果在 SELECT 或 EXAMINE 期间返回 UIDNOTSTICKY 响应代码,您还会看到每次 SELECT 或 EXAMINE 邮箱时邮箱(文件夹的 IMAP 术语)上的 UIDVALIDITY 值都会发生变化。但无论如何,您都必须检查 UIDVALIDITY 是否发生更改,因为邮箱的 UIDVALIDITY 不能保证不可变,并且任何此类更改都会使您缓存的 UID 无效。是的,UIDVALIDITY 值通常不会改变。但是您的代码必须处理这种情况,并且通过这样做您还可以覆盖 UIDNOTSTICKY 情况。
If the UIDNOTSTICKY response code is returned during a SELECT or EXAMINE, you'll also see that the UIDVALIDITY value on the mailbox (the IMAP term for a folder) changes every time you SELECT or EXAMINE the mailbox. But you have to check for a change in UIDVALIDITY anyway since the mailbox's UIDVALIDITY is not guaranteed immutable, and any such change invalidates your cached UIDs. Yes, UIDVALIDITY values generally don't change. But your code's going to have to deal with that case, and by doing so you'll have also covered the UIDNOTSTICKY case.