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

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2285 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-04-07 21:20:25 +00:00
parent 89d0ed029f
commit dd1cfea379
1 changed files with 13 additions and 2 deletions

View File

@ -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");