1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Remove remnants of the "headers" table

This commit is contained in:
cketti 2015-01-06 21:36:31 +01:00
parent d7edb0ed4f
commit 30e37000f9
3 changed files with 4 additions and 52 deletions

View File

@ -1472,7 +1472,9 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
Part attachment = attachments.get(i); Part attachment = attachments.get(i);
saveAttachment(message.getId(), attachment, false); saveAttachment(message.getId(), attachment, false);
} }
saveHeaders(message.getId(), message);
//FIXME
//saveHeaders(message.getId(), message);
} catch (Exception e) { } catch (Exception e) {
throw new MessagingException("Error appending message", e); throw new MessagingException("Error appending message", e);
} }
@ -1489,54 +1491,6 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
this.localStore.notifyChange(); this.localStore.notifyChange();
} }
/**
* Save the headers of the given message. Note that the message is not
* necessarily a {@link LocalMessage} instance.
* @param id
* @param message
* @throws com.fsck.k9.mail.MessagingException
*/
private void saveHeaders(final long id, final MimeMessage message) throws MessagingException {
this.localStore.database.execute(true, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, MessagingException {
deleteHeaders(id);
for (String name : message.getHeaderNames()) {
String[] values = message.getHeader(name);
for (String value : values) {
ContentValues cv = new ContentValues();
cv.put("message_id", id);
cv.put("name", name);
cv.put("value", value);
db.insert("headers", "name", cv);
}
}
// Remember that all headers for this message have been saved, so it is
// not necessary to download them again in case the user wants to see all headers.
List<Flag> appendedFlags = new ArrayList<Flag>();
appendedFlags.addAll(message.getFlags());
appendedFlags.add(Flag.X_GOT_ALL_HEADERS);
db.execSQL("UPDATE messages " + "SET flags = ? " + " WHERE id = ?",
new Object[] { LocalFolder.this.localStore.serializeFlags(appendedFlags), id });
return null;
}
});
}
void deleteHeaders(final long id) throws MessagingException {
this.localStore.database.execute(false, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
db.execSQL("DELETE FROM headers WHERE message_id = ?", new Object[] { id });
return null;
}
});
}
/** /**
* @param messageId * @param messageId
* @param attachment * @param attachment

View File

@ -341,7 +341,6 @@ public class LocalMessage extends MimeMessage {
} catch (WrappedException e) { } catch (WrappedException e) {
throw(MessagingException) e.getCause(); throw(MessagingException) e.getCause();
} }
((LocalFolder)mFolder).deleteHeaders(mId);
this.localStore.notifyChange(); this.localStore.notifyChange();
} }

View File

@ -180,8 +180,7 @@ class StoreSchemaDefinition implements LockableDatabase.SchemaDefinition {
db.execSQL("CREATE TRIGGER delete_folder BEFORE DELETE ON folders BEGIN DELETE FROM messages WHERE old.id = folder_id; END;"); db.execSQL("CREATE TRIGGER delete_folder BEFORE DELETE ON folders BEGIN DELETE FROM messages WHERE old.id = folder_id; END;");
db.execSQL("DROP TRIGGER IF EXISTS delete_message"); db.execSQL("DROP TRIGGER IF EXISTS delete_message");
db.execSQL("CREATE TRIGGER delete_message BEFORE DELETE ON messages BEGIN DELETE FROM attachments WHERE old.id = message_id; " db.execSQL("CREATE TRIGGER delete_message BEFORE DELETE ON messages BEGIN DELETE FROM attachments WHERE old.id = message_id; END;");
+ "DELETE FROM headers where old.id = message_id; END;");
} else { } else {
// in the case that we're starting out at 29 or newer, run all the needed updates // in the case that we're starting out at 29 or newer, run all the needed updates