mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
EWS: rely on uid (PR_SEARCH_KEY) instead of permanentUrl to detect imap uid changes
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1120 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
72ee220550
commit
190a39cad7
@ -25,8 +25,6 @@ import davmail.exception.DavMailException;
|
|||||||
import davmail.http.DavGatewayHttpClientFacade;
|
import davmail.http.DavGatewayHttpClientFacade;
|
||||||
import davmail.http.DavGatewayOTPPrompt;
|
import davmail.http.DavGatewayOTPPrompt;
|
||||||
import davmail.util.StringUtil;
|
import davmail.util.StringUtil;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.codec.binary.Hex;
|
|
||||||
import org.apache.commons.httpclient.*;
|
import org.apache.commons.httpclient.*;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.commons.httpclient.methods.PostMethod;
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
@ -1099,9 +1097,9 @@ public abstract class ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public ExchangeSession.MessageList messages;
|
public ExchangeSession.MessageList messages;
|
||||||
/**
|
/**
|
||||||
* PermanentURL to UID map.
|
* Permanent uid (PR_SEARCH_KEY) to IMAP UID map.
|
||||||
*/
|
*/
|
||||||
private final HashMap<String, Long> uidUrlHashMap = new HashMap<String, Long>();
|
private final HashMap<String, Long> uidToImapUidMap = new HashMap<String, Long>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get IMAP folder flags.
|
* Get IMAP folder flags.
|
||||||
@ -1149,16 +1147,16 @@ public abstract class ExchangeSession {
|
|||||||
protected void fixUids(MessageList messages) {
|
protected void fixUids(MessageList messages) {
|
||||||
boolean sortNeeded = false;
|
boolean sortNeeded = false;
|
||||||
for (Message message : messages) {
|
for (Message message : messages) {
|
||||||
if (uidUrlHashMap.containsKey(message.getPermanentUrl())) {
|
if (uidToImapUidMap.containsKey(message.getUid())) {
|
||||||
long previousUid = uidUrlHashMap.get(message.getPermanentUrl());
|
long previousUid = uidToImapUidMap.get(message.getUid());
|
||||||
if (message.getImapUid() != previousUid) {
|
if (message.getImapUid() != previousUid) {
|
||||||
LOGGER.debug("Restoring IMAP uid " + message.getImapUid() + " -> " + previousUid + " for message " + message.getPermanentUrl() + " (" + message.messageUrl + ')');
|
LOGGER.debug("Restoring IMAP uid " + message.getImapUid() + " -> " + previousUid + " for message uid " + message.getUid());
|
||||||
message.setImapUid(previousUid);
|
message.setImapUid(previousUid);
|
||||||
sortNeeded = true;
|
sortNeeded = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// add message to uid map
|
// add message to uid map
|
||||||
uidUrlHashMap.put(message.getPermanentUrl(), message.getImapUid());
|
uidToImapUidMap.put(message.getUid(), message.getImapUid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sortNeeded) {
|
if (sortNeeded) {
|
||||||
|
Loading…
Reference in New Issue
Block a user