Remove UnavailableAccountException
This commit is contained in:
parent
fb8f98486f
commit
0167d8dfef
3 changed files with 1 additions and 85 deletions
|
@ -77,7 +77,6 @@ import com.fsck.k9.mailstore.OutboxStateRepository;
|
|||
import com.fsck.k9.mailstore.SaveMessageData;
|
||||
import com.fsck.k9.mailstore.SaveMessageDataCreator;
|
||||
import com.fsck.k9.mailstore.SendState;
|
||||
import com.fsck.k9.mailstore.UnavailableStorageException;
|
||||
import com.fsck.k9.notification.NotificationController;
|
||||
import com.fsck.k9.notification.NotificationStrategy;
|
||||
import com.fsck.k9.power.TracingPowerManager;
|
||||
|
@ -216,23 +215,7 @@ public class MessagingController {
|
|||
command.sequence,
|
||||
command.isForegroundPriority ? "foreground" : "background");
|
||||
|
||||
try {
|
||||
command.runnable.run();
|
||||
} catch (UnavailableAccountException e) {
|
||||
// retry later
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(30 * 1000);
|
||||
queuedCommands.put(command);
|
||||
} catch (InterruptedException e) {
|
||||
Timber.e("Interrupted while putting a pending command for an unavailable account " +
|
||||
"back into the queue. THIS SHOULD NEVER HAPPEN.");
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
command.runnable.run();
|
||||
|
||||
Timber.i(" Command '%s' completed", command.description);
|
||||
}
|
||||
|
@ -741,10 +724,6 @@ public class MessagingController {
|
|||
public void run() {
|
||||
try {
|
||||
processPendingCommandsSynchronous(account);
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to process pending command because storage is not available - " +
|
||||
"trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (MessagingException me) {
|
||||
Timber.e(me, "processPendingCommands");
|
||||
|
||||
|
@ -1623,9 +1602,6 @@ public class MessagingController {
|
|||
notificationController.showSendFailedNotification(account, lastFailure);
|
||||
}
|
||||
}
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to send pending messages because storage is not available - trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (Exception e) {
|
||||
Timber.v(e, "Failed to send pending messages");
|
||||
} finally {
|
||||
|
@ -1891,9 +1867,6 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
processPendingCommands(account);
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to move/copy message because storage is not available - trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (MessagingException me) {
|
||||
throw new RuntimeException("Error moving message", me);
|
||||
}
|
||||
|
@ -2138,9 +2111,6 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
unsuppressMessages(account, messages);
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to delete message because storage is not available - trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (MessagingException me) {
|
||||
throw new RuntimeException("Error deleting message from local store.", me);
|
||||
}
|
||||
|
@ -2210,9 +2180,6 @@ public class MessagingController {
|
|||
queuePendingCommand(account, command);
|
||||
processPendingCommands(account);
|
||||
}
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to empty trash because storage is not available - trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "emptyTrash failed");
|
||||
}
|
||||
|
@ -2232,9 +2199,6 @@ public class MessagingController {
|
|||
LocalFolder localFolder = localStoreProvider.getInstance(account).getFolder(folderId);
|
||||
localFolder.open();
|
||||
localFolder.clearAllMessages();
|
||||
} catch (UnavailableStorageException e) {
|
||||
Timber.i("Failed to clear folder because storage is not available - trying again later.");
|
||||
throw new UnavailableAccountException(e);
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "clearFolder failed");
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package com.fsck.k9.controller;
|
||||
|
||||
/**
|
||||
* An {@link com.fsck.k9.Account} is not
|
||||
* {@link com.fsck.k9.Account#isAvailable(android.content.Context)}.<br/>
|
||||
* The operation may be retried later.
|
||||
*/
|
||||
public class UnavailableAccountException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1827283277120501465L;
|
||||
|
||||
public UnavailableAccountException() {
|
||||
super("please try again later");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param detailMessage
|
||||
* @param throwable
|
||||
*/
|
||||
public UnavailableAccountException(String detailMessage, Throwable throwable) {
|
||||
super(detailMessage, throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param detailMessage
|
||||
*/
|
||||
public UnavailableAccountException(String detailMessage) {
|
||||
super(detailMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param throwable
|
||||
*/
|
||||
public UnavailableAccountException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ import com.fsck.k9.mailstore.OutboxState;
|
|||
import com.fsck.k9.mailstore.OutboxStateRepository;
|
||||
import com.fsck.k9.mailstore.SaveMessageDataCreator;
|
||||
import com.fsck.k9.mailstore.SendState;
|
||||
import com.fsck.k9.mailstore.UnavailableStorageException;
|
||||
import com.fsck.k9.notification.NotificationController;
|
||||
import com.fsck.k9.notification.NotificationStrategy;
|
||||
import com.fsck.k9.preferences.Protocols;
|
||||
|
@ -168,13 +167,6 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
verify(localFolder).clearAllMessages();
|
||||
}
|
||||
|
||||
@Test(expected = UnavailableAccountException.class)
|
||||
public void clearFolderSynchronous_whenStorageUnavailable_shouldThrowUnavailableAccountException() throws MessagingException {
|
||||
doThrow(new UnavailableStorageException("Test")).when(localFolder).open();
|
||||
|
||||
controller.clearFolderSynchronous(account, FOLDER_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshRemoteSynchronous_shouldCallBackend() throws MessagingException {
|
||||
controller.refreshFolderListSynchronous(account);
|
||||
|
|
Loading…
Reference in a new issue