Cloud sync: fixes

pull/212/head
M66B 2 years ago
parent f17aa78ad2
commit 76c6fc2e6c

@ -232,7 +232,7 @@ public class CloudSync {
return;
}
List<EntityAccount> accounts = db.account().getSynchronizingAccounts(null);
List<EntityAccount> accounts = db.account().getAccounts();
EntityLog.log(context, EntityLog.Type.Cloud,
"Cloud accounts=" + (accounts == null ? null : accounts.size()));
if (accounts == null || accounts.size() == 0)
@ -242,14 +242,14 @@ public class CloudSync {
JSONArray jaccountuuidlist = new JSONArray();
for (EntityAccount account : accounts)
if (!TextUtils.isEmpty(account.uuid)) {
if (account.synchronize && !TextUtils.isEmpty(account.uuid)) {
jaccountuuidlist.put(account.uuid);
JSONArray jidentitieuuids = new JSONArray();
List<EntityIdentity> identities = db.identity().getIdentities(account.id);
if (identities != null)
for (EntityIdentity identity : identities)
if (!TextUtils.isEmpty(identity.uuid)) {
if (identity.synchronize && !TextUtils.isEmpty(identity.uuid)) {
jidentitieuuids.put(identity.uuid);
JSONObject jidentity = identity.toJSON();
@ -377,7 +377,7 @@ public class CloudSync {
"Cloud account " + raccount.uuid + "=" +
(laccount == null ? "insert" :
(EntityAccount.areEqual(raccount, laccount,
laccount.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD, true)
laccount.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD, false)
? "equal" : "update")) +
" rev=" + revision +
" left=" + (left == null ? null : left.name + ":" + left.type) +
@ -483,13 +483,12 @@ public class CloudSync {
"Cloud identity " + ridentity.uuid + "=" +
(lidentity == null ? "insert" :
(EntityIdentity.areEqual(ridentity, lidentity,
lidentity.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD, true)
lidentity.auth_type == ServiceAuthenticator.AUTH_TYPE_PASSWORD, false)
? "equal" : "update")) +
" rev=" + revision +
" size=" + value.length());
ridentity.id = null;
ridentity.primary = false;
ridentity.last_modified = rrevision;
try {
@ -503,6 +502,7 @@ public class CloudSync {
}
} else {
ridentity.id = lidentity.id;
ridentity.account = lidentity.account;
db.identity().updateIdentity(ridentity);
}

@ -561,7 +561,7 @@ public abstract class DB extends RoomDatabase {
" AFTER UPDATE ON account" +
" BEGIN" +
" UPDATE account SET last_modified = strftime('%s') * 1000" +
" WHERE id = NEW.id" +
" WHERE OLD.id = NEW.id" +
" AND OLD.last_modified = NEW.last_modified" +
" AND (NEW.auth_type = " + AUTH_TYPE_PASSWORD + " OR OLD.password = NEW.password)" +
" AND OLD.keep_alive_ok IS NEW.keep_alive_ok" +
@ -580,7 +580,7 @@ public abstract class DB extends RoomDatabase {
" AFTER UPDATE ON identity" +
" BEGIN" +
" UPDATE identity SET last_modified = strftime('%s') * 1000" +
" WHERE id = NEW.id" +
" WHERE OLD.id = NEW.id" +
" AND OLD.last_modified = NEW.last_modified" +
" AND OLD.state IS NEW.state" +
" AND OLD.error IS NEW.error" +

Loading…
Cancel
Save