mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
IMAP: implement EXPUNGE untagged response on NOOP to avoid NO message not found on Exchange message message uid change
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@867 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1769cda706
commit
d05ae65cdf
@ -1115,22 +1115,24 @@ public class ExchangeSession {
|
||||
* Check folder ctag and reload messages as needed.
|
||||
*
|
||||
* @param currentFolder current folder
|
||||
* @return current folder or new refreshed folder
|
||||
* @return true if folder changed
|
||||
* @throws IOException on error
|
||||
* @deprecated no longer used: breaks Outlook IMAP
|
||||
*/
|
||||
@Deprecated
|
||||
public Folder refreshFolder(Folder currentFolder) throws IOException {
|
||||
public boolean refreshFolder(Folder currentFolder) throws IOException {
|
||||
Folder newFolder = getFolder(currentFolder.folderName);
|
||||
if (currentFolder.contenttag == null || !currentFolder.contenttag.equals(newFolder.contenttag)) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Contenttag changed on " + currentFolder.folderName + ' '
|
||||
+ currentFolder.contenttag + " => " + newFolder.contenttag + ", reloading messages");
|
||||
}
|
||||
newFolder.loadMessages();
|
||||
return newFolder;
|
||||
currentFolder.hasChildren = newFolder.hasChildren;
|
||||
currentFolder.noInferiors = newFolder.noInferiors;
|
||||
currentFolder.unreadCount = newFolder.unreadCount;
|
||||
currentFolder.contenttag = newFolder.contenttag;
|
||||
currentFolder.loadMessages();
|
||||
return true;
|
||||
} else {
|
||||
return currentFolder;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,10 +399,26 @@ public class ImapConnection extends AbstractConnection {
|
||||
} else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) {
|
||||
if (currentFolder != null) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_IMAP_COMMAND", command, currentFolder.folderName));
|
||||
currentFolder = session.getFolder(currentFolder.folderName);
|
||||
currentFolder.loadMessages();
|
||||
sendClient("* " + currentFolder.count() + " EXISTS");
|
||||
sendClient("* " + currentFolder.count() + " RECENT");
|
||||
ExchangeSession.MessageList currentMessages = currentFolder.messages;
|
||||
if (session.refreshFolder(currentFolder)) {
|
||||
// build new uid set
|
||||
HashSet<Long> uidSet = new HashSet<Long>();
|
||||
for (ExchangeSession.Message message : currentFolder.messages) {
|
||||
uidSet.add(message.getImapUid());
|
||||
}
|
||||
// send expunge untagged response for removed IMAP message uids
|
||||
// note: some STORE commands trigger a uid change in Exchange,
|
||||
// thus those messages are expunged and reappear with a new uid
|
||||
int index = 1;
|
||||
for (ExchangeSession.Message message : currentMessages) {
|
||||
if (!uidSet.contains(message.getImapUid())) {
|
||||
sendClient("* " + index + " EXPUNGE");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
sendClient("* " + currentFolder.count() + " EXISTS");
|
||||
sendClient("* " + currentFolder.count() + " RECENT");
|
||||
}
|
||||
}
|
||||
sendClient(commandId + " OK " + command + " completed");
|
||||
} else if ("subscribe".equalsIgnoreCase(command) || "unsubscribe".equalsIgnoreCase(command)) {
|
||||
|
Loading…
Reference in New Issue
Block a user