From 416aafb940c33ba75d59c5d08b276c2e4cd570c6 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 1 Nov 2008 04:26:03 +0000 Subject: [PATCH] extract the 'upgrade database' method. Since K-9 never had a pre-v18 database, I'm inclined to kill it, except it may serve as a useful template for the future --- src/com/fsck/k9/mail/store/LocalStore.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index bc5eeb991..d97f0b293 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -83,6 +83,19 @@ public class LocalStore extends Store { } mDb = SQLiteDatabase.openOrCreateDatabase(mPath, null); if (mDb.getVersion() != DB_VERSION) { + doDbUpgrade(mDb); + } + + + mAttachmentsDir = new File(mPath + "_att"); + if (!mAttachmentsDir.exists()) { + mAttachmentsDir.mkdirs(); + } + } + + + private void doDbUpgrade ( SQLiteDatabase mDb) { + if (mDb.getVersion() < 18) { if (Config.LOGV) { Log.v(k9.LOG_TAG, String.format("Upgrading database from %d to %d", mDb @@ -117,11 +130,6 @@ public class LocalStore extends Store { throw new Error("Database upgrade failed!"); } } - mAttachmentsDir = new File(mPath + "_att"); - if (!mAttachmentsDir.exists()) { - mAttachmentsDir.mkdirs(); - } - } @Override public Folder getFolder(String name) throws MessagingException { @@ -374,7 +382,7 @@ public class LocalStore extends Store { } mDb.execSQL("INSERT INTO folders (name, visible_limit) VALUES (?, ?)", new Object[] { mName, - 25 + k9.DEFAULT_VISIBLE_LIMIT }); return true; }