Autocorrect uuids

pull/213/head
M66B 1 year ago
parent f881e81949
commit 3ffce527cb

@ -56,6 +56,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -269,7 +270,8 @@ public class CloudSync {
account.auth_type != ServiceAuthenticator.AUTH_TYPE_GMAIL) {
if (uuidAccounts.contains(account.uuid)) {
Log.w("Duplicate account uuid=" + account.uuid);
continue;
account.uuid = UUID.randomUUID().toString();
db.account().setAccountUuid(account.id, account.uuid);
} else
uuidAccounts.add(account.uuid);
@ -282,7 +284,8 @@ public class CloudSync {
if (identity.synchronize && !TextUtils.isEmpty(identity.uuid)) {
if (uuidIdentities.contains(identity.uuid)) {
Log.w("Duplicate identity uuid=" + identity.uuid);
continue;
identity.uuid = UUID.randomUUID().toString();
db.identity().setIdentityUuid(identity.id, identity.uuid);
} else
uuidIdentities.add(identity.uuid);

@ -192,6 +192,9 @@ public interface DaoAccount {
@Update
void updateAccount(EntityAccount account);
@Query("UPDATE account SET uuid = :uuid WHERE id = :id AND NOT (uuid IS :uuid)")
int setAccountUuid(long id, String uuid);
@Query("UPDATE account SET synchronize = :synchronize WHERE id = :id AND NOT (synchronize IS :synchronize)")
int setAccountSynchronize(long id, boolean synchronize);

@ -105,6 +105,9 @@ public interface DaoIdentity {
@Update
void updateIdentity(EntityIdentity identity);
@Query("UPDATE identity SET uuid = :uuid WHERE id = :id AND NOT (uuid IS :uuid)")
int setIdentityUuid(long id, String uuid);
@Query("UPDATE identity SET synchronize = :synchronize WHERE id = :id AND NOT (synchronize IS :synchronize)")
int setIdentitySynchronize(long id, boolean synchronize);

Loading…
Cancel
Save