Serialize sync on init

This commit is contained in:
M66B 2019-05-22 09:33:25 +02:00
parent 4b832db3fc
commit e52b52b2ba
2 changed files with 16 additions and 3 deletions

View File

@ -1188,8 +1188,10 @@ class Core {
}
}
if (state.running)
if (state.running) {
folder.initialize = false;
db.folder().setFolderInitialized(folder.id);
}
db.folder().setFolderSync(folder.id, new Date().getTime());
db.folder().setFolderError(folder.id, null);

View File

@ -96,6 +96,7 @@ public class ServiceSynchronize extends LifecycleService {
private long lastLost = 0;
private TupleAccountStats lastStats = new TupleAccountStats();
private ExecutorService queue = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
private ExecutorService initExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
private static boolean booted = false;
private static boolean oneshot = false;
@ -931,8 +932,18 @@ public class ServiceSynchronize extends LifecycleService {
handling = ops;
if (handling.size() > 0 && process) {
Log.i(folder.name + " operations=" + operations.size());
(folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() {
Log.i(folder.name + " operations=" + operations.size() +
" init=" + folder.initialize + " poll=" + folder.poll);
ExecutorService executor;
if (folder.initialize)
executor = initExecutor;
else if (folder.poll)
executor = pollExecutor;
else
executor = folderExecutor;
executor.submit(new Runnable() {
@Override
public void run() {
try {