1
0
mirror of https://github.com/etesync/android synced 2025-02-02 19:01:06 +00:00

SyncManager: Request for a full sync if interrupted.

This doesn't work well, but I'm keeping it since it's still better than
what was there before.

We have a problem that on initial sync with long enough logs, Android
kills the sync manager before completion. The reason for that is that
due to the fact that EteSync first downloads the whole journal and only then
processes it, the sync manager spends a minute without making any
network traffic, which in turn makes Android kill the sync[1].

This should probably be fixed by paginating the initial download, that
is, downloading and processing the journal in chunks, which is possibly
a good idea regardless.

1: https://developer.android.com/reference/android/content/AbstractThreadedSyncAdapter.html
This commit is contained in:
Tom Hacohen 2017-05-03 18:28:35 +01:00
parent a107cd3fa2
commit 20568c850a

View File

@ -140,51 +140,51 @@ abstract public class SyncManager {
}
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_query_capabilities;
App.log.info("Sync phase: " + context.getString(syncPhase));
queryCapabilities();
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_prepare_local;
App.log.info("Sync phase: " + context.getString(syncPhase));
prepareLocal();
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_fetch_entries;
App.log.info("Sync phase: " + context.getString(syncPhase));
fetchEntries();
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_apply_remote_entries;
App.log.info("Sync phase: " + context.getString(syncPhase));
applyRemoteEntries();
/* Create journal entries out of local changes. */
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_create_local_entries;
App.log.info("Sync phase: " + context.getString(syncPhase));
createLocalEntries();
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_apply_local_entries;
App.log.info("Sync phase: " + context.getString(syncPhase));
applyLocalEntries();
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_push_entries;
App.log.info("Sync phase: " + context.getString(syncPhase));
pushEntries();
/* Cleanup and finalize changes */
if (Thread.interrupted())
return;
throw new InterruptedException();
syncPhase = R.string.sync_phase_post_processing;
App.log.info("Sync phase: " + context.getString(syncPhase));
postProcess();
@ -197,7 +197,8 @@ abstract public class SyncManager {
syncResult.stats.numIoExceptions++;
syncResult.delayUntil = (e.retryAfter > 0) ? e.retryAfter : Constants.DEFAULT_RETRY_DELAY;
} catch (InterruptedException e) {
// Restart sync if interrupted
syncResult.fullSyncRequested = true;
} catch (Exception | OutOfMemoryError e) {
if (e instanceof Exceptions.UnauthorizedException) {
syncResult.stats.numAuthExceptions++;