mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
Delete the old localized outbox. Fixes the "two outboxes" problem.
Rename the "new" hardcoded outbox to "K9MAIL_INTERNAL_OUTBOX". This is done to avoid collisions with folders named "OUTBOX" in a remote store. See https://groups.google.com/group/k-9-mail/browse_thread/thread/cbb1c77abba84695 Fixes issue 3411
This commit is contained in:
parent
eb68df9070
commit
1bdf7095a7
@ -41,7 +41,7 @@ public class Account implements BaseAccount {
|
|||||||
/**
|
/**
|
||||||
* This local folder is used to store messages to be sent.
|
* This local folder is used to store messages to be sent.
|
||||||
*/
|
*/
|
||||||
public static final String OUTBOX = "OUTBOX";
|
public static final String OUTBOX = "K9MAIL_INTERNAL_OUTBOX";
|
||||||
|
|
||||||
public static final String EXPUNGE_IMMEDIATELY = "EXPUNGE_IMMEDIATELY";
|
public static final String EXPUNGE_IMMEDIATELY = "EXPUNGE_IMMEDIATELY";
|
||||||
public static final String EXPUNGE_MANUALLY = "EXPUNGE_MANUALLY";
|
public static final String EXPUNGE_MANUALLY = "EXPUNGE_MANUALLY";
|
||||||
|
@ -33,6 +33,7 @@ import com.fsck.k9.Account;
|
|||||||
import com.fsck.k9.AccountStats;
|
import com.fsck.k9.AccountStats;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.controller.MessageRemovalListener;
|
import com.fsck.k9.controller.MessageRemovalListener;
|
||||||
import com.fsck.k9.controller.MessageRetrievalListener;
|
import com.fsck.k9.controller.MessageRetrievalListener;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
@ -101,7 +102,7 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
static private String GET_FOLDER_COLS = "id, name, unread_count, visible_limit, last_updated, status, push_state, last_pushed, flagged_count, integrate, top_group, poll_class, push_class, display_class";
|
static private String GET_FOLDER_COLS = "id, name, unread_count, visible_limit, last_updated, status, push_state, last_pushed, flagged_count, integrate, top_group, poll_class, push_class, display_class";
|
||||||
|
|
||||||
|
|
||||||
protected static final int DB_VERSION = 42;
|
protected static final int DB_VERSION = 43;
|
||||||
|
|
||||||
protected String uUid = null;
|
protected String uUid = null;
|
||||||
|
|
||||||
@ -329,6 +330,40 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
Log.e(K9.LOG_TAG, "Could not replace Preferences in upgrade from DB_VERSION 41", e);
|
Log.e(K9.LOG_TAG, "Could not replace Preferences in upgrade from DB_VERSION 41", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (db.getVersion() < 43) {
|
||||||
|
try {
|
||||||
|
// If folder "OUTBOX" (old, v3.800 - v3.802) exists, rename it to
|
||||||
|
// "K9MAIL_INTERNAL_OUTBOX" (new)
|
||||||
|
LocalFolder oldOutbox = new LocalFolder("OUTBOX");
|
||||||
|
if (oldOutbox.exists()) {
|
||||||
|
ContentValues cv = new ContentValues();
|
||||||
|
cv.put("name", Account.OUTBOX);
|
||||||
|
db.update("folders", cv, "name = ?", new String[] { "OUTBOX" });
|
||||||
|
Log.i(K9.LOG_TAG, "Renamed folder OUTBOX to " + Account.OUTBOX);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if old (pre v3.800) localized outbox folder exists
|
||||||
|
String localizedOutbox = K9.app.getString(R.string.special_mailbox_name_outbox);
|
||||||
|
LocalFolder obsoleteOutbox = new LocalFolder(localizedOutbox);
|
||||||
|
if (obsoleteOutbox.exists()) {
|
||||||
|
// Get all messages from the localized outbox ...
|
||||||
|
Message[] messages = obsoleteOutbox.getMessages(null, false);
|
||||||
|
|
||||||
|
if (messages.length > 0) {
|
||||||
|
// ... and move them to the drafts folder (we don't want to
|
||||||
|
// surprise the user by sending potentially very old messages)
|
||||||
|
LocalFolder drafts = new LocalFolder(mAccount.getDraftsFolderName());
|
||||||
|
obsoleteOutbox.moveMessages(messages, drafts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now get rid of the localized outbox
|
||||||
|
obsoleteOutbox.delete();
|
||||||
|
obsoleteOutbox.delete(true);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(K9.LOG_TAG, "Error trying to fix the outbox folders", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user