Commit 45a319dc authored by Mickaël Guessant's avatar Mickaël Guessant

IMAP: implement separate thread folder load on STATUS request to avoid client timeouts

git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@2285 3d1905a2-6b24-0410-a738-b14d5a86fcbd
parent 302a721e
......@@ -569,7 +569,18 @@ public class ImapConnection extends AbstractConnection {
String folderName = BASE64MailboxDecoder.decode(encodedFolderName);
ExchangeSession.Folder folder = session.getFolder(folderName);
// must retrieve messages
folder.loadMessages();
// use folder.loadMessages() for small folders only
LOGGER.debug("*");
os.write('*');
if (folder.count() <= 500) {
// simple folder load
folder.loadMessages();
} else {
// load folder in a separate thread
FolderLoadThread.loadFolder(folder, os);
}
String parameters = tokens.nextToken();
StringBuilder answer = new StringBuilder();
StringTokenizer parametersTokens = new StringTokenizer(parameters);
......@@ -600,7 +611,7 @@ public class ImapConnection extends AbstractConnection {
answer.append("UNSEEN ").append(folder.unreadCount).append(' ');
}
}
sendClient("* STATUS \"" + encodedFolderName + "\" (" + answer.toString().trim() + ')');
sendClient(" STATUS \"" + encodedFolderName + "\" (" + answer.toString().trim() + ')');
sendClient(commandId + " OK " + command + " completed");
} catch (HttpException e) {
sendClient(commandId + " NO folder not found");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment