am fa93a71b: am b62067e3: Make sure old body files don\'t contaminate new messages
* commit 'fa93a71b29e4db566f989d7e2c2fea559b83a305': Make sure old body files don't contaminate new messages
This commit is contained in:
commit
2ba65aec8c
|
@ -758,12 +758,9 @@ public class EmailProvider extends ContentProvider
|
||||||
if (messageDeletion) {
|
if (messageDeletion) {
|
||||||
if (match == MESSAGE_ID) {
|
if (match == MESSAGE_ID) {
|
||||||
// Delete the Body record associated with the deleted message
|
// Delete the Body record associated with the deleted message
|
||||||
final ContentValues emptyValues = new ContentValues(2);
|
|
||||||
emptyValues.putNull(BodyColumns.HTML_CONTENT);
|
|
||||||
emptyValues.putNull(BodyColumns.TEXT_CONTENT);
|
|
||||||
final long messageId = Long.valueOf(id);
|
final long messageId = Long.valueOf(id);
|
||||||
try {
|
try {
|
||||||
writeBodyFiles(context, messageId, emptyValues);
|
deleteBodyFiles(context, messageId);
|
||||||
} catch (final IllegalStateException e) {
|
} catch (final IllegalStateException e) {
|
||||||
LogUtils.v(LogUtils.TAG, e, "Exception while deleting bodies");
|
LogUtils.v(LogUtils.TAG, e, "Exception while deleting bodies");
|
||||||
}
|
}
|
||||||
|
@ -772,13 +769,10 @@ public class EmailProvider extends ContentProvider
|
||||||
// Delete any orphaned Body records
|
// Delete any orphaned Body records
|
||||||
final Cursor orphans = db.rawQuery(ORPHAN_BODY_MESSAGE_ID_SELECT, null);
|
final Cursor orphans = db.rawQuery(ORPHAN_BODY_MESSAGE_ID_SELECT, null);
|
||||||
try {
|
try {
|
||||||
final ContentValues emptyValues = new ContentValues(2);
|
|
||||||
emptyValues.putNull(BodyColumns.HTML_CONTENT);
|
|
||||||
emptyValues.putNull(BodyColumns.TEXT_CONTENT);
|
|
||||||
while (orphans.moveToNext()) {
|
while (orphans.moveToNext()) {
|
||||||
final long messageId = orphans.getLong(0);
|
final long messageId = orphans.getLong(0);
|
||||||
try {
|
try {
|
||||||
writeBodyFiles(context, messageId, emptyValues);
|
deleteBodyFiles(context, messageId);
|
||||||
} catch (final IllegalStateException e) {
|
} catch (final IllegalStateException e) {
|
||||||
LogUtils.v(LogUtils.TAG, e, "Exception while deleting bodies");
|
LogUtils.v(LogUtils.TAG, e, "Exception while deleting bodies");
|
||||||
}
|
}
|
||||||
|
@ -908,6 +902,8 @@ public class EmailProvider extends ContentProvider
|
||||||
"Cannot insert body without MESSAGE_KEY");
|
"Cannot insert body without MESSAGE_KEY");
|
||||||
}
|
}
|
||||||
final long messageId = values.getAsLong(BodyColumns.MESSAGE_KEY);
|
final long messageId = values.getAsLong(BodyColumns.MESSAGE_KEY);
|
||||||
|
// Ensure that no pre-existing body files contaminate the message
|
||||||
|
deleteBodyFiles(context, messageId);
|
||||||
writeBodyFiles(getContext(), messageId, values);
|
writeBodyFiles(getContext(), messageId, values);
|
||||||
break;
|
break;
|
||||||
// NOTE: It is NOT legal for production code to insert directly into UPDATED_MESSAGE
|
// NOTE: It is NOT legal for production code to insert directly into UPDATED_MESSAGE
|
||||||
|
@ -2220,6 +2216,14 @@ public class EmailProvider extends ContentProvider
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void deleteBodyFiles(final Context c, final long messageId)
|
||||||
|
throws IllegalStateException {
|
||||||
|
final ContentValues emptyValues = new ContentValues(2);
|
||||||
|
emptyValues.putNull(BodyColumns.HTML_CONTENT);
|
||||||
|
emptyValues.putNull(BodyColumns.TEXT_CONTENT);
|
||||||
|
writeBodyFiles(c, messageId, emptyValues);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes message bodies to disk, read from a set of ContentValues
|
* Writes message bodies to disk, read from a set of ContentValues
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue