commit
19de9ff7b7
6 changed files with 27 additions and 4 deletions
|
@ -960,10 +960,14 @@ public class LocalStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long createLocalFolder(String folderName, FolderType type) throws MessagingException {
|
public long createLocalFolder(String folderName, FolderType type) throws MessagingException {
|
||||||
|
return createLocalFolder(folderName, folderName, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long createLocalFolder(String folderServerId, String folderName, FolderType type) throws MessagingException {
|
||||||
return database.execute(true, (DbCallback<Long>) db -> {
|
return database.execute(true, (DbCallback<Long>) db -> {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("name", folderName);
|
values.put("name", folderName);
|
||||||
values.put("server_id", folderName);
|
values.put("server_id", folderServerId);
|
||||||
values.put("local_only", 1);
|
values.put("local_only", 1);
|
||||||
values.put("type", FolderTypeConverter.toDatabaseFolderType(type));
|
values.put("type", FolderTypeConverter.toDatabaseFolderType(type));
|
||||||
values.put("visible_limit", 0);
|
values.put("visible_limit", 0);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class SpecialLocalFoldersCreator(
|
||||||
|
|
||||||
val localStore = localStoreProvider.getInstance(account)
|
val localStore = localStoreProvider.getInstance(account)
|
||||||
|
|
||||||
account.outboxFolderId = localStore.createLocalFolder(OUTBOX_FOLDER_NAME, FolderType.OUTBOX)
|
account.outboxFolderId = localStore.createLocalFolder(OUTBOX_SERVER_ID, OUTBOX_FOLDER_NAME, FolderType.OUTBOX)
|
||||||
|
|
||||||
if (account.isPop3()) {
|
if (account.isPop3()) {
|
||||||
check(account.draftsFolderId == null) { "Drafts folder was already set up" }
|
check(account.draftsFolderId == null) { "Drafts folder was already set up" }
|
||||||
|
@ -37,6 +37,7 @@ class SpecialLocalFoldersCreator(
|
||||||
private fun Account.isPop3() = storeUri.startsWith("pop3")
|
private fun Account.isPop3() = storeUri.startsWith("pop3")
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val OUTBOX_SERVER_ID = Account.OUTBOX
|
||||||
private const val OUTBOX_FOLDER_NAME = Account.OUTBOX_NAME
|
private const val OUTBOX_FOLDER_NAME = Account.OUTBOX_NAME
|
||||||
private const val DRAFTS_FOLDER_NAME = "Drafts"
|
private const val DRAFTS_FOLDER_NAME = "Drafts"
|
||||||
private const val SENT_FOLDER_NAME = "Sent"
|
private const val SENT_FOLDER_NAME = "Sent"
|
||||||
|
|
|
@ -52,7 +52,7 @@ class JmapAccountCreator(
|
||||||
|
|
||||||
private fun createOutboxFolder(account: Account) {
|
private fun createOutboxFolder(account: Account) {
|
||||||
val localStore = localStoreProvider.getInstance(account)
|
val localStore = localStoreProvider.getInstance(account)
|
||||||
account.outboxFolderId = localStore.createLocalFolder(Account.OUTBOX_NAME, FolderType.OUTBOX)
|
account.outboxFolderId = localStore.createLocalFolder(Account.OUTBOX, Account.OUTBOX_NAME, FolderType.OUTBOX)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchFolderList(account: Account) {
|
private fun fetchFolderList(account: Account) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import timber.log.Timber;
|
||||||
|
|
||||||
|
|
||||||
class StoreSchemaDefinition implements SchemaDefinition {
|
class StoreSchemaDefinition implements SchemaDefinition {
|
||||||
static final int DB_VERSION = 76;
|
static final int DB_VERSION = 77;
|
||||||
|
|
||||||
private final MigrationsHelper migrationsHelper;
|
private final MigrationsHelper migrationsHelper;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.fsck.k9.storage.migrations
|
||||||
|
|
||||||
|
import android.content.ContentValues
|
||||||
|
import android.database.sqlite.SQLiteDatabase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure local Outbox folder has correct 'server_id' value
|
||||||
|
*/
|
||||||
|
internal class MigrationTo77(private val db: SQLiteDatabase) {
|
||||||
|
fun cleanUpOutboxServerId() {
|
||||||
|
val values = ContentValues().apply {
|
||||||
|
put("server_id", "K9MAIL_INTERNAL_OUTBOX")
|
||||||
|
}
|
||||||
|
|
||||||
|
db.update("folders", values, "name = 'Outbox' AND local_only = 1", null)
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,5 +22,6 @@ object Migrations {
|
||||||
if (oldVersion < 74) MigrationTo74(db, migrationsHelper.account).removeDeletedMessages()
|
if (oldVersion < 74) MigrationTo74(db, migrationsHelper.account).removeDeletedMessages()
|
||||||
if (oldVersion < 75) MigrationTo75(db, migrationsHelper).updateAccountWithSpecialFolderIds()
|
if (oldVersion < 75) MigrationTo75(db, migrationsHelper).updateAccountWithSpecialFolderIds()
|
||||||
if (oldVersion < 76) MigrationTo76(db, migrationsHelper).cleanUpSpecialLocalFolders()
|
if (oldVersion < 76) MigrationTo76(db, migrationsHelper).cleanUpSpecialLocalFolders()
|
||||||
|
if (oldVersion < 77) MigrationTo77(db).cleanUpOutboxServerId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue