Assume attachment when not inline

pull/180/head
M66B 5 years ago
parent 5c1b5352be
commit 3dac4d407e

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 162, version = 164,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -282,7 +282,7 @@ public abstract class DB extends RoomDatabase {
" BEGIN" + " BEGIN" +
" UPDATE message SET attachments = attachments + 1" + " UPDATE message SET attachments = attachments + 1" +
" WHERE message.id = NEW.message" + " WHERE message.id = NEW.message" +
" AND NEW.disposition = 'attachment'" + " AND (NEW.disposition IS NULL OR NEW.disposition <> 'inline')" +
" AND (NEW.encryption IS NULL OR NEW.encryption = 0);" + " AND (NEW.encryption IS NULL OR NEW.encryption = 0);" +
" END"); " END");
db.execSQL("CREATE TRIGGER IF NOT EXISTS attachment_delete" + db.execSQL("CREATE TRIGGER IF NOT EXISTS attachment_delete" +
@ -290,7 +290,7 @@ public abstract class DB extends RoomDatabase {
" BEGIN" + " BEGIN" +
" UPDATE message SET attachments = attachments - 1" + " UPDATE message SET attachments = attachments - 1" +
" WHERE message.id = OLD.message" + " WHERE message.id = OLD.message" +
" AND OLD.disposition = 'attachment'" + " AND (OLD.disposition IS NULL OR OLD.disposition <> 'inline')" +
" AND (OLD.encryption IS NULL OR OLD.encryption = 0);" + " AND (OLD.encryption IS NULL OR OLD.encryption = 0);" +
" END"); " END");
} }
@ -1607,6 +1607,24 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `verified` INTEGER NOT NULL DEFAULT 0"); db.execSQL("ALTER TABLE `message` ADD COLUMN `verified` INTEGER NOT NULL DEFAULT 0");
} }
})
.addMigrations(new Migration(162, 163) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("DROP TRIGGER attachment_insert");
db.execSQL("DROP TRIGGER attachment_delete");
createTriggers(db);
}
})
.addMigrations(new Migration(163, 164) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("DROP TRIGGER attachment_insert");
db.execSQL("DROP TRIGGER attachment_delete");
createTriggers(db);
}
}); });
} }

Loading…
Cancel
Save