Cloud checks

pull/212/head
M66B 3 years ago
parent 2ae3f845a9
commit c223f8ef1e

@ -1544,7 +1544,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
JSONObject jstatus = new JSONObject(); JSONObject jstatus = new JSONObject();
jstatus.put("key", "sync.status"); jstatus.put("key", "sync.status");
jstatus.put("rev", 0); jstatus.put("rev", sync_status * 0);
JSONArray jitems = new JSONArray(); JSONArray jitems = new JSONArray();
jitems.put(jstatus); jitems.put(jstatus);
@ -1624,57 +1624,64 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
String uuid = juuids.getString(i); String uuid = juuids.getString(i);
JSONObject jaccount = new JSONObject(); JSONObject jaccount = new JSONObject();
jaccount.put("key", "account." + uuid); jaccount.put("key", "account." + uuid);
jaccount.put("rev", 0); jaccount.put("rev", sync_status * 0);
jdownload.put(jaccount); jdownload.put(jaccount);
Log.i("Cloud account " + uuid); Log.i("Cloud account " + uuid);
} }
jrequest.put("items", jdownload); if (jdownload.length() > 0) {
jresponse = CloudSync.perform(context, user, password, jrequest); Log.i("Cloud getting accounts");
jrequest.put("items", jdownload);
// Process accounts jresponse = CloudSync.perform(context, user, password, jrequest);
jitems = jresponse.getJSONArray("items");
jdownload = new JSONArray(); // Process accounts
for (int i = 0; i < jitems.length(); i++) { Log.i("Cloud processing accounts");
JSONObject jaccount = jitems.getJSONObject(i); jitems = jresponse.getJSONArray("items");
String key = jaccount.getString("key"); jdownload = new JSONArray();
String value = jaccount.getString("val"); for (int i = 0; i < jitems.length(); i++) {
int revision = jaccount.getInt("rev"); JSONObject jaccount = jitems.getJSONObject(i);
String uuid = key.split("\\.")[1]; String key = jaccount.getString("key");
EntityAccount account = db.account().getAccountByUUID(uuid); String value = jaccount.getString("val");
JSONObject jaccountdata = new JSONObject(value); int revision = jaccount.getInt("rev");
JSONArray jidentities = jaccountdata.getJSONArray("identities"); String uuid = key.split("\\.")[1];
Log.i("Cloud account " + uuid + "=" + (account != null) + EntityAccount account = db.account().getAccountByUUID(uuid);
" rev=" + revision + JSONObject jaccountdata = new JSONObject(value);
" identities=" + jidentities + JSONArray jidentities = jaccountdata.getJSONArray("identities");
" size=" + value.length()); Log.i("Cloud account " + uuid + "=" + (account != null) +
" rev=" + revision +
for (int j = 0; j < jidentities.length(); j++) { " identities=" + jidentities +
JSONObject jidentity = new JSONObject(); " size=" + value.length());
jidentity.put("key", "identity." + jidentities.getString(j));
jidentity.put("rev", 0); for (int j = 0; j < jidentities.length(); j++) {
jdownload.put(jidentity); JSONObject jidentity = new JSONObject();
jidentity.put("key", "identity." + jidentities.getString(j));
jidentity.put("rev", sync_status);
jdownload.put(jidentity);
}
} }
}
// Get identities if (jdownload.length() > 0) {
jrequest.put("items", jdownload); // Get identities
jresponse = CloudSync.perform(context, user, password, jrequest); Log.i("Cloud getting identities");
jrequest.put("items", jdownload);
// Process identities jresponse = CloudSync.perform(context, user, password, jrequest);
jitems = jresponse.getJSONArray("items");
for (int i = 0; i < jitems.length(); i++) { // Process identities
JSONObject jaccount = jitems.getJSONObject(i); Log.i("Cloud processing identities");
String key = jaccount.getString("key"); jitems = jresponse.getJSONArray("items");
String value = jaccount.getString("val"); for (int i = 0; i < jitems.length(); i++) {
int revision = jaccount.getInt("rev"); JSONObject jaccount = jitems.getJSONObject(i);
String uuid = key.split("\\.")[1]; String key = jaccount.getString("key");
EntityIdentity identity = db.identity().getIdentityByUUID(uuid); String value = jaccount.getString("val");
Log.i("Cloud identity " + uuid + "=" + (identity != null) + int revision = jaccount.getInt("rev");
" rev=" + revision + String uuid = key.split("\\.")[1];
" size=" + value.length()); EntityIdentity identity = db.identity().getIdentityByUUID(uuid);
Log.i("Cloud identity " + uuid + "=" + (identity != null) +
" rev=" + revision +
" size=" + value.length());
}
}
} }
} else { } else {
// No changes // No changes
} }

Loading…
Cancel
Save