Skip to content

Commit

Permalink
Cleaned up LocalFolder.appendMessages() a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed Feb 16, 2012
1 parent 023c605 commit c3885bc
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/com/fsck/k9/mail/store/LocalStore.java
Expand Up @@ -2090,16 +2090,27 @@ public Void doDbWork(final SQLiteDatabase db) throws WrappedException, Unavailab

long oldMessageId = -1;
String uid = message.getUid();
if (uid == null && !copy) {
uid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
message.setUid(uid);
} else if (copy) {
String randomLocalUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
if (uid != null) {
if (uid == null || copy) {
/*
* Create a new message in the database
*/
String randomLocalUid = K9.LOCAL_UID_PREFIX +
UUID.randomUUID().toString();

if (copy) {
// Save mapping: source UID -> target UID
uidMap.put(uid, randomLocalUid);
} else {
// Modify the Message instance to reference the new UID
message.setUid(randomLocalUid);
}

// The message will be saved with the newly generated UID
uid = randomLocalUid;
} else {
/*
* Replace an existing message in the database
*/
LocalMessage oldMessage = (LocalMessage) getMessage(uid);

if (oldMessage != null) {
Expand Down

0 comments on commit c3885bc

Please sign in to comment.