mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 00:21:10 +00:00
Simplification
This commit is contained in:
parent
fbf258fa89
commit
662d3a6c2e
1 changed files with 2 additions and 13 deletions
|
@ -564,24 +564,13 @@ public abstract class DB extends RoomDatabase {
|
|||
}
|
||||
|
||||
private static void createTriggers(@NonNull SupportSQLiteDatabase db) {
|
||||
List<String> image = new ArrayList<>();
|
||||
for (String img : ImageHelper.IMAGE_TYPES)
|
||||
image.add("'" + img + "'");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
for (String img : ImageHelper.IMAGE_TYPES8)
|
||||
image.add("'" + img + "'");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
|
||||
for (String img : ImageHelper.IMAGE_TYPES12)
|
||||
image.add("'" + img + "'");
|
||||
String images = TextUtils.join(",", image);
|
||||
|
||||
db.execSQL("CREATE TRIGGER IF NOT EXISTS attachment_insert" +
|
||||
" AFTER INSERT ON attachment" +
|
||||
" BEGIN" +
|
||||
" UPDATE message SET attachments = attachments + 1" +
|
||||
" WHERE message.id = NEW.message" +
|
||||
" AND NEW.encryption IS NULL" +
|
||||
" AND NOT ((NEW.disposition = 'inline' OR (NEW.related IS NOT 0 AND NEW.cid IS NOT NULL)) AND NEW.type IN (" + images + "));" +
|
||||
" AND NOT ((NEW.disposition = 'inline' OR (NEW.related IS NOT 0 AND NEW.cid IS NOT NULL)) AND NEW.type LIKE 'image/%');" +
|
||||
" END");
|
||||
db.execSQL("CREATE TRIGGER IF NOT EXISTS attachment_delete" +
|
||||
" AFTER DELETE ON attachment" +
|
||||
|
@ -589,7 +578,7 @@ public abstract class DB extends RoomDatabase {
|
|||
" UPDATE message SET attachments = attachments - 1" +
|
||||
" WHERE message.id = OLD.message" +
|
||||
" AND OLD.encryption IS NULL" +
|
||||
" AND NOT ((OLD.disposition = 'inline' OR (OLD.related IS NOT 0 AND OLD.cid IS NOT NULL)) AND OLD.type IN (" + images + "));" +
|
||||
" AND NOT ((OLD.disposition = 'inline' OR (OLD.related IS NOT 0 AND OLD.cid IS NOT NULL)) AND OLD.type LIKE 'image/%');" +
|
||||
" END");
|
||||
|
||||
db.execSQL("CREATE TRIGGER IF NOT EXISTS account_update" +
|
||||
|
|
Loading…
Add table
Reference in a new issue