1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-07 03:38:05 -05:00

IMAP: send error on COPY/MOVE when message iterator is empty

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1908 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-02-09 23:15:19 +00:00
parent 4d6e87b346
commit f70ba39fe1

View File

@ -331,16 +331,20 @@ public class ImapConnection extends AbstractConnection {
try { try {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken()); UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken()); String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (uidRangeIterator.hasNext()) { if (!uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon(); sendClient(commandId + " NO " + "No message found");
ExchangeSession.Message message = uidRangeIterator.next(); } else {
if ("copy".equalsIgnoreCase(subcommand)) { while (uidRangeIterator.hasNext()) {
session.copyMessage(message, targetName); DavGatewayTray.switchIcon();
} else { ExchangeSession.Message message = uidRangeIterator.next();
session.moveMessage(message, targetName); if ("copy".equalsIgnoreCase(subcommand)) {
session.copyMessage(message, targetName);
} else {
session.moveMessage(message, targetName);
}
} }
sendClient(commandId + " OK " + subcommand + " completed");
} }
sendClient(commandId + " OK "+subcommand+" completed");
} catch (HttpException e) { } catch (HttpException e) {
sendClient(commandId + " NO " + e.getMessage()); sendClient(commandId + " NO " + e.getMessage());
} }
@ -402,16 +406,20 @@ public class ImapConnection extends AbstractConnection {
try { try {
RangeIterator rangeIterator = new RangeIterator(currentFolder.messages, tokens.nextToken()); RangeIterator rangeIterator = new RangeIterator(currentFolder.messages, tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken()); String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (rangeIterator.hasNext()) { if (!rangeIterator.hasNext()) {
DavGatewayTray.switchIcon(); sendClient(commandId + " NO " + "No message found");
ExchangeSession.Message message = rangeIterator.next(); } else {
if ("copy".equalsIgnoreCase(command)) { while (rangeIterator.hasNext()) {
session.copyMessage(message, targetName); DavGatewayTray.switchIcon();
} else { ExchangeSession.Message message = rangeIterator.next();
session.moveMessage(message, targetName); if ("copy".equalsIgnoreCase(command)) {
session.copyMessage(message, targetName);
} else {
session.moveMessage(message, targetName);
}
} }
sendClient(commandId + " OK "+command+" completed");
} }
sendClient(commandId + " OK "+command+" completed");
} catch (HttpException e) { } catch (HttpException e) {
sendClient(commandId + " NO " + e.getMessage()); sendClient(commandId + " NO " + e.getMessage());
} }