Fix sync issues

* Always sync every list - https://issuetracker.google.com/issues/136123247
* Return empty string when password decryption fails
* Exclude more non-fatal exception reports
pull/848/head 6.7.3
Alex Baker 5 years ago
parent 56f3dceec7
commit 6ca900e991

@ -25,8 +25,8 @@ android {
defaultConfig {
testApplicationId = "org.tasks.test"
applicationId = "org.tasks"
versionCode = 592
versionName = "6.7.2"
versionCode = 596
versionName = "6.7.3"
targetSdkVersion(Versions.compileSdk)
minSdkVersion(Versions.minSdk)
multiDexEnabled = true

@ -6,9 +6,6 @@
package com.todoroo.astrid.gtasks;
import static com.google.common.collect.Lists.newArrayList;
import static org.tasks.time.DateTimeUtils.printTimestamp;
import com.google.api.services.tasks.model.TaskList;
import com.todoroo.astrid.service.TaskDeleter;
import java.util.HashSet;
@ -94,24 +91,6 @@ public class GtasksListService {
localBroadcastManager.broadcastRefreshList();
}
public List<GoogleTaskList> getListsToUpdate(List<TaskList> remoteLists) {
List<GoogleTaskList> listsToUpdate = newArrayList();
for (TaskList remoteList : remoteLists) {
GoogleTaskList localList = getList(remoteList.getId());
long lastSync = localList.getLastSync();
long lastUpdate = remoteList.getUpdated().getValue();
if (lastSync < lastUpdate) {
listsToUpdate.add(localList);
Timber.d(
"%s out of date [local=%s] [remote=%s]",
localList.getTitle(), printTimestamp(lastSync), printTimestamp(lastUpdate));
} else {
Timber.d("%s up to date", localList.getTitle());
}
}
return listsToUpdate;
}
public GoogleTaskList getList(String listId) {
return googleTaskListDao.getByRemoteId(listId);
}

@ -30,6 +30,9 @@ public abstract class GoogleTaskListDao {
@Query("SELECT * FROM google_task_lists WHERE remote_id = :remoteId LIMIT 1")
public abstract GoogleTaskList getByRemoteId(String remoteId);
@Query("SELECT * FROM google_task_lists WHERE remote_id IN (:remoteIds)")
public abstract List<GoogleTaskList> getByRemoteId(List<String> remoteIds);
@Query("SELECT * FROM google_task_lists")
public abstract LiveData<List<GoogleTaskList>> subscribeToLists();

@ -1,5 +1,6 @@
package org.tasks.gtasks;
import static com.google.common.collect.Lists.transform;
import static org.tasks.date.DateTimeUtils.newDateTime;
import android.app.PendingIntent;
@ -27,8 +28,10 @@ import com.todoroo.astrid.gtasks.sync.GtasksTaskContainer;
import com.todoroo.astrid.service.TaskCreator;
import com.todoroo.astrid.service.TaskDeleter;
import com.todoroo.astrid.utility.Constants;
import java.io.EOFException;
import java.io.IOException;
import java.net.ConnectException;
import java.net.HttpRetryException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
@ -143,9 +146,21 @@ public class GoogleTaskSynchronizer {
} else {
account.setError(context.getString(R.string.requires_pro_subscription));
}
} catch (SocketTimeoutException | SSLException | ConnectException | UnknownHostException e) {
} catch (SocketTimeoutException
| SSLException
| SocketException
| UnknownHostException
| HttpRetryException
| EOFException e) {
Timber.e(e);
account.setError(e.getMessage());
} catch (GoogleJsonResponseException e) {
account.setError(e.getMessage());
if (e.getStatusCode() == 401) {
Timber.e(e);
} else {
tracker.reportException(e);
}
} catch (UserRecoverableAuthIOException e) {
Timber.e(e);
sendNotification(context, e.getIntent());
@ -214,7 +229,8 @@ public class GoogleTaskSynchronizer {
preferences.setString(R.string.p_default_remote_list, null);
}
}
for (GoogleTaskList list : gtasksListService.getListsToUpdate(gtaskLists)) {
for (GoogleTaskList list :
googleTaskListDao.getByRemoteId(transform(gtaskLists, TaskList::getId))) {
fetchAndApplyRemoteChanges(gtasksInvoker, list);
if (!preferences.isPositionHackEnabled()) {
googleTaskDao.reposition(list.getRemoteId());

@ -78,7 +78,7 @@ public class KeyStoreEncryption implements Encryption {
return new String(decrypted, ENCODING);
} catch (IllegalBlockSizeException | BadPaddingException e) {
Timber.e(e);
return null;
return "";
}
}

Loading…
Cancel
Save