From c94804df2689984c7b418bfe04336fb48bd079d4 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 19 Jan 2017 15:53:28 +0100 Subject: [PATCH] use CHILD_PART_CONTAINS_DATA as data location for multipart (fixes #1899) --- .../java/com/fsck/k9/mailstore/LocalFolder.java | 2 +- .../java/com/fsck/k9/mailstore/LocalStore.java | 2 +- .../k9/mailstore/migrations/MigrationTo57.java | 15 +++++++++++++++ .../fsck/k9/mailstore/migrations/Migrations.java | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo57.java diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java index 9cd8f2319..39fa993ff 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java @@ -1438,7 +1438,7 @@ public class LocalFolder extends Folder implements Serializable { } private void multipartToContentValues(ContentValues cv, Multipart multipart) { - cv.put("data_location", DataLocation.IN_DATABASE); + cv.put("data_location", DataLocation.CHILD_PART_CONTAINS_DATA); cv.put("preamble", multipart.getPreamble()); cv.put("epilogue", multipart.getEpilogue()); cv.put("boundary", multipart.getBoundary()); diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java index 5f669ae81..7a125314e 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalStore.java @@ -153,7 +153,7 @@ public class LocalStore extends Store implements Serializable { */ private static final int THREAD_FLAG_UPDATE_BATCH_SIZE = 500; - public static final int DB_VERSION = 56; + public static final int DB_VERSION = 57; public static String getColumnNameForFlag(Flag flag) { diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo57.java b/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo57.java new file mode 100644 index 000000000..6519069de --- /dev/null +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/MigrationTo57.java @@ -0,0 +1,15 @@ +package com.fsck.k9.mailstore.migrations; + + +import android.database.sqlite.SQLiteDatabase; + + +class MigrationTo57 { + private static final int IN_DATABASE = 1; + private static final int CHILD_PART_CONTAINS_DATA = 3; + + static void fixDataLocationForMultipartParts(SQLiteDatabase db) { + db.execSQL("UPDATE message_parts SET data_location = " + CHILD_PART_CONTAINS_DATA + " " + + "WHERE data_location = " + IN_DATABASE + " AND mime_type LIKE 'multipart/%'"); + } +} diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/Migrations.java b/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/Migrations.java index 7666b5256..fe483c641 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/Migrations.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/migrations/Migrations.java @@ -66,6 +66,8 @@ public class Migrations { MigrationTo55.createFtsSearchTable(db, migrationsHelper); case 55: MigrationTo56.cleanUpFtsTable(db); + case 56: + MigrationTo57.fixDataLocationForMultipartParts(db); } } }