Skip idle when transient connection

This commit is contained in:
M66B 2020-12-26 17:16:20 +01:00
parent acbc601b56
commit f8dbf957b9
1 changed files with 24 additions and 22 deletions

View File

@ -1283,30 +1283,32 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}); });
// Idle folder // Idle folder
Thread idler = new Thread(new Runnable() { if (!account.isTransient(this)) {
@Override Thread idler = new Thread(new Runnable() {
public void run() { @Override
try { public void run() {
Log.i(folder.name + " start idle"); try {
while (ifolder.isOpen() && state.isRunning() && state.isRecoverable()) { Log.i(folder.name + " start idle");
Log.i(folder.name + " do idle"); while (ifolder.isOpen() && state.isRunning() && state.isRecoverable()) {
ifolder.idle(false); Log.i(folder.name + " do idle");
state.activity(); ifolder.idle(false);
state.activity();
}
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Log.formatThrowable(ex, false));
state.error(new FolderClosedException(ifolder, "IDLE", new Exception(ex)));
} finally {
Log.i(folder.name + " end idle");
} }
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Log.formatThrowable(ex, false));
state.error(new FolderClosedException(ifolder, "IDLE", new Exception(ex)));
} finally {
Log.i(folder.name + " end idle");
} }
} }, "idler." + folder.id);
}, "idler." + folder.id); idler.setPriority(THREAD_PRIORITY_BACKGROUND);
idler.setPriority(THREAD_PRIORITY_BACKGROUND); idler.start();
idler.start(); idlers.add(idler);
idlers.add(idler); }
EntityOperation.sync(this, folder.id, false, force && !forced); EntityOperation.sync(this, folder.id, false, force && !forced);