Fix backup
This commit is contained in:
parent
d842f00411
commit
a23cd0358f
|
@ -117,7 +117,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
||||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||||
try {
|
try {
|
||||||
//Starts from the last recorded ID
|
//Starts from the last recorded ID
|
||||||
Date sinceDate = new StatusCacheDAO(BackupStatusInDataBaseService.this, db).getLastTootDateCache(StatusCacheDAO.ARCHIVE_CACHE);
|
Date sinceDate = new StatusCacheDAO(BackupStatusInDataBaseService.this, db).getLastTootDateCache(StatusCacheDAO.ARCHIVE_CACHE, userId, instance);
|
||||||
String max_id = null;
|
String max_id = null;
|
||||||
List<Status> backupStatus = new ArrayList<>();
|
List<Status> backupStatus = new ArrayList<>();
|
||||||
boolean canContinue = true;
|
boolean canContinue = true;
|
||||||
|
@ -130,7 +130,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
||||||
canContinue = false;
|
canContinue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
new StatusCacheDAO(BackupStatusInDataBaseService.this, db).insertStatus(StatusCacheDAO.ARCHIVE_CACHE, tmpStatus);
|
new StatusCacheDAO(BackupStatusInDataBaseService.this, db).insertStatus(StatusCacheDAO.ARCHIVE_CACHE, tmpStatus, userId, instance);
|
||||||
backupStatus.add(tmpStatus);
|
backupStatus.add(tmpStatus);
|
||||||
}
|
}
|
||||||
}while (max_id != null && canContinue);
|
}while (max_id != null && canContinue);
|
||||||
|
|
|
@ -424,10 +424,12 @@ public class StatusCacheDAO {
|
||||||
* Returns the last date of backup for a user depending of the type of cache
|
* Returns the last date of backup for a user depending of the type of cache
|
||||||
* @return Date
|
* @return Date
|
||||||
*/
|
*/
|
||||||
public Date getLastTootDateCache(int cacheType){
|
public Date getLastTootDateCache(int cacheType, String userId, String instance){
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
if( userId == null || instance == null) {
|
||||||
String instance = Helper.getLiveInstance(context);
|
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
instance = Helper.getLiveInstance(context);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_CREATED_AT + " DESC", "1");
|
Cursor c = db.query(Sqlite.TABLE_STATUSES_CACHE, null, Sqlite.COL_CACHED_ACTION + " = '" + cacheType+ "' AND " + Sqlite.COL_INSTANCE + " = '" + instance+ "' AND " + Sqlite.COL_USER_ID + " = '" + userId+ "'", null, null, null, Sqlite.COL_CREATED_AT + " DESC", "1");
|
||||||
//No element found
|
//No element found
|
||||||
|
|
Loading…
Reference in New Issue