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());
|
||||
try {
|
||||
//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;
|
||||
List<Status> backupStatus = new ArrayList<>();
|
||||
boolean canContinue = true;
|
||||
|
@ -130,7 +130,7 @@ public class BackupStatusInDataBaseService extends IntentService {
|
|||
canContinue = false;
|
||||
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);
|
||||
}
|
||||
}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
|
||||
* @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);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = Helper.getLiveInstance(context);
|
||||
if( userId == null || instance == null) {
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = Helper.getLiveInstance(context);
|
||||
}
|
||||
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");
|
||||
//No element found
|
||||
|
|
Loading…
Reference in New Issue