From a4ac9e00e9e5a6eed6ad8b9202ef8cf84e8d03da Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 20 Jan 2023 08:31:12 +0100 Subject: [PATCH] Cloud sync: last modification improvements --- app/src/main/java/eu/faircode/email/AdapterIdentity.java | 4 +++- app/src/main/java/eu/faircode/email/DB.java | 8 +++++--- app/src/main/java/eu/faircode/email/EntityIdentity.java | 3 ++- app/src/main/java/eu/faircode/email/FragmentAccount.java | 2 -- app/src/main/java/eu/faircode/email/FragmentIdentity.java | 1 - 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterIdentity.java b/app/src/main/java/eu/faircode/email/AdapterIdentity.java index 1b5821bd31..2a233ee20a 100644 --- a/app/src/main/java/eu/faircode/email/AdapterIdentity.java +++ b/app/src/main/java/eu/faircode/email/AdapterIdentity.java @@ -174,7 +174,9 @@ public class AdapterIdentity extends RecyclerView.Adapter 0 ? View.VISIBLE : View.GONE); tvLast.setText(context.getString(R.string.title_last_connected, - (identity.last_connected == null ? "-" : DTF.format(identity.last_connected)))); + (identity.last_connected == null ? "-" : DTF.format(identity.last_connected))) + + (BuildConfig.DEBUG ? + "/" + (identity.last_modified == null ? "-" : DTF.format(identity.last_modified)) : "")); tvMaxSize.setText(identity.max_size == null ? null : Helper.humanReadableByteCount(identity.max_size)); tvMaxSize.setVisibility(identity.max_size == null ? View.GONE : View.VISIBLE); diff --git a/app/src/main/java/eu/faircode/email/DB.java b/app/src/main/java/eu/faircode/email/DB.java index ae48686311..72fae3789e 100644 --- a/app/src/main/java/eu/faircode/email/DB.java +++ b/app/src/main/java/eu/faircode/email/DB.java @@ -489,7 +489,7 @@ public abstract class DB extends RoomDatabase { Log.i("Get PRAGMA " + pragma + "="); } - if (BuildConfig.DEBUG && false) { + if (BuildConfig.DEBUG) { db.execSQL("DROP TRIGGER IF EXISTS `attachment_insert`"); db.execSQL("DROP TRIGGER IF EXISTS `attachment_delete`"); @@ -561,14 +561,16 @@ public abstract class DB extends RoomDatabase { " AFTER UPDATE ON account" + " BEGIN" + " UPDATE account SET last_modified = strftime('%s') * 1000" + - " WHERE (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + + " WHERE id = NEW.id" + + " AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + " END"); db.execSQL("CREATE TRIGGER IF NOT EXISTS identity_update" + " AFTER UPDATE ON identity" + " BEGIN" + " UPDATE identity SET last_modified = strftime('%s') * 1000" + - " WHERE (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + + " WHERE id = NEW.id" + + " AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password);" + " END"); } diff --git a/app/src/main/java/eu/faircode/email/EntityIdentity.java b/app/src/main/java/eu/faircode/email/EntityIdentity.java index 690f4ab50a..da0a8d79ec 100644 --- a/app/src/main/java/eu/faircode/email/EntityIdentity.java +++ b/app/src/main/java/eu/faircode/email/EntityIdentity.java @@ -364,7 +364,8 @@ public class EntityIdentity { (!state || Objects.equals(i1.state, other.state)) && (!state || Objects.equals(i1.error, other.error)) && (!state || Objects.equals(i1.last_connected, other.last_connected)) && - (!state || Objects.equals(i1.max_size, other.max_size))); + (!state || Objects.equals(i1.max_size, other.max_size)) && + (!state || Objects.equals(i1.last_modified, other.last_modified))); } String getDisplayName() { diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index e77e2f6608..8a49847a22 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -1288,8 +1288,6 @@ public class FragmentAccount extends FragmentBase { account.warning = null; account.error = null; account.last_connected = last_connected; - account.last_modified = new Date().getTime(); - // SET last_modified = strftime('%s') * 1000 if (account.primary) db.account().resetPrimary(); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 6338cbbb24..7286e441f6 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -1018,7 +1018,6 @@ public class FragmentIdentity extends FragmentBase { identity.error = null; identity.last_connected = last_connected; identity.max_size = (user_max_size == null ? server_max_size : user_max_size); - identity.last_modified = new Date().getTime(); if (identity.primary) db.identity().resetPrimary(account);