Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93bc2794 authored by cketti's avatar cketti
Browse files

Merge pull request #1406 from k9mail/no-purge-download-for-view

Do not purge messages when downloading missing body for view
parents f0e64a33 59a81849
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -971,7 +971,7 @@ public class MessagingController implements Runnable {
            /*
             * Now we download the actual content of messages.
             */
            int newMessages = downloadMessages(account, remoteFolder, localFolder, remoteMessages, false);
            int newMessages = downloadMessages(account, remoteFolder, localFolder, remoteMessages, false, true);

            int unreadMessageCount = localFolder.getUnreadMessageCount();
            for (MessagingListener l : getListeners()) {
@@ -1108,6 +1108,8 @@ public class MessagingController implements Runnable {
     *            A list of messages objects that store the UIDs of which messages to download.
     * @param flagSyncOnly
     *            Only flags will be fetched from the remote store if this is {@code true}.
     * @param purgeToVisibleLimit
     *            If true, local messages will be purged down to the limit of visible messages.
     *
     * @return The number of downloaded messages that are not flagged as {@link Flag#SEEN}.
     *
@@ -1115,7 +1117,7 @@ public class MessagingController implements Runnable {
     */
    private int downloadMessages(final Account account, final Folder remoteFolder,
            final LocalFolder localFolder, List<Message> inputMessages,
                                 boolean flagSyncOnly) throws MessagingException {
            boolean flagSyncOnly, boolean purgeToVisibleLimit) throws MessagingException {

        final Date earliestDate = account.getEarliestPollDate();
        Date downloadStarted = new Date(); // now
@@ -1233,6 +1235,7 @@ public class MessagingController implements Runnable {
        if (K9.DEBUG)
            Log.d(K9.LOG_TAG, "SYNC: Synced remote messages for folder " + folder + ", " + newMessages.get() + " new messages");

        if (purgeToVisibleLimit) {
            localFolder.purgeToVisibleLimit(new MessageRemovalListener() {
                @Override
                public void messageRemoved(Message message) {
@@ -1242,6 +1245,7 @@ public class MessagingController implements Runnable {
                }

            });
        }

        // If the oldest message seen on this sync is newer than
        // the oldest message seen on the previous sync, then
@@ -2770,7 +2774,7 @@ public class MessagingController implements Runnable {

                if (loadPartialFromSearch) {
                    downloadMessages(account, remoteFolder, localFolder,
                            Collections.singletonList(remoteMessage), false);
                            Collections.singletonList(remoteMessage), false, false);
                } else {
                    FetchProfile fp = new FetchProfile();
                    fp.add(FetchProfile.Item.BODY);
@@ -4562,7 +4566,7 @@ public class MessagingController implements Runnable {
                    localFolder.open(Folder.OPEN_MODE_RW);

                    account.setRingNotified(false);
                    int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly);
                    int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly, true);

                    int unreadMessageCount = localFolder.getUnreadMessageCount();