From 6cfcfb953f1604e77769a77dd78d60a5e7c2f2c2 Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Sun, 25 Apr 2010 06:17:15 +0000 Subject: [PATCH] Aggressively get rid of obsolete Flag X_NO_SEEN_INFO. It was interfering with "unread" searches on POP3 accounts. Flags really should be normalized in the database to eliminate the use of LIKE while searching by Flags. --- src/com/fsck/k9/mail/Flag.java | 4 --- src/com/fsck/k9/mail/store/LocalStore.java | 29 +++++++++++++++++----- src/com/fsck/k9/mail/store/Pop3Store.java | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/com/fsck/k9/mail/Flag.java b/src/com/fsck/k9/mail/Flag.java index d29325039..706abf5d2 100644 --- a/src/com/fsck/k9/mail/Flag.java +++ b/src/com/fsck/k9/mail/Flag.java @@ -19,10 +19,6 @@ public enum Flag * these flags and Strings to represent user defined flags. At that point the below * flags should become user defined flags. */ - /* - * For POP3 to indicate that the message does not have SEEN info - */ - X_NO_SEEN_INFO, /** * Delete and remove from the LocalStore immediately. */ diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 90fad1b5a..ce533c667 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -34,7 +34,7 @@ import java.util.regex.Matcher; */ public class LocalStore extends Store implements Serializable { - private static final int DB_VERSION = 34; + private static final int DB_VERSION = 35; private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED }; private String mPath; @@ -215,6 +215,17 @@ public class LocalStore extends Store implements Serializable } } } + if (mDb.getVersion() < 35) + { + try + { + mDb.execSQL("update messages set flags = replace(flags, 'X_NO_SEEN_INFO', 'X_BAD_FLAG')"); + } + catch (SQLiteException e) + { + Log.e(K9.LOG_TAG, "Unable to get rid of obsolete flag X_NO_SEEN_INFO", e); + } + } } @@ -2357,15 +2368,21 @@ public class LocalStore extends Store implements Serializable if (flagList != null && flagList.length() > 0) { String[] flags = flagList.split(","); - try + + for (String flag : flags) { - for (String flag : flags) + try { this.setFlagInternal(Flag.valueOf(flag), true); } - } - catch (Exception e) - { + + catch (Exception e) + { + if ("X_BAD_FLAG".equals(flag) == false) + { + Log.w(K9.LOG_TAG, "Unable to parse flag " + flag); + } + } } } this.mId = cursor.getLong(5); diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index cb5156104..6415156fa 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -1094,7 +1094,6 @@ public class Pop3Store extends Store mUid = uid; mFolder = folder; mSize = -1; - mFlags.add(Flag.X_NO_SEEN_INFO); } public void setSize(int size)