1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-02 00:25:10 -04:00

factor common code out of downloadLargeMessages and

downloadSmallMessages (catching a missing condition in one)
This commit is contained in:
Jesse Vincent 2010-07-13 21:17:04 +00:00
parent 70a1eef943
commit 986237d31f

View File

@ -1679,6 +1679,33 @@ public class MessagingController implements Runnable
});
}
private boolean shouldImportMessage(final Account account, final String folder, final Message message, final AtomicInteger progress, final Date earliestDate)
{
if (isMessageSuppressed(account, folder, message))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " was suppressed "+
"but just downloaded. "+
"The race condition means we wasted some bandwidth. Oh well.");
}
return false;
}
if (message.olderThan(earliestDate))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " is older than "
+ earliestDate + ", hence not saving");
}
return false;
}
return true;
}
private void downloadSmallMessages(final Account account, final Folder remoteFolder,
final LocalFolder localFolder,
ArrayList<Message> smallMessages,
@ -1703,27 +1730,8 @@ public class MessagingController implements Runnable
try
{
if (isMessageSuppressed(account, folder, message))
if (!shouldImportMessage(account, folder, message, progress, earliestDate))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " was suppressed "+
"but just downloaded. "+
"The race condition means we wasted some bandwidth. Oh well.");
}
progress.incrementAndGet();
return;
}
if (message.olderThan(earliestDate))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " is older than "
+ earliestDate + ", hence not saving");
}
progress.incrementAndGet();
return;
@ -1800,17 +1808,13 @@ public class MessagingController implements Runnable
remoteFolder.fetch(largeMessages.toArray(new Message[largeMessages.size()]), fp, null);
for (Message message : largeMessages)
{
if (message.olderThan(earliestDate))
{
if (K9.DEBUG)
{
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " is older than "
+ earliestDate + ", hence not saving");
}
progress.incrementAndGet();
if (!shouldImportMessage(account, folder, message, progress, earliestDate))
{
progress.incrementAndGet();
continue;
}
if (message.getBody() == null)
{
/*