Revert "Process newly arrived operations only"

This reverts commit cb1ded8ecf.
This commit is contained in:
M66B 2019-01-29 15:41:16 +00:00
parent cb1ded8ecf
commit 7ddcc119e6
1 changed files with 22 additions and 33 deletions

View File

@ -1189,19 +1189,18 @@ public class ServiceSynchronize extends LifecycleService {
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
@Override
public void onChanged(final List<EntityOperation> ops) {
final List<EntityOperation> arrived = new ArrayList<>();
synchronized (handling) {
for (EntityOperation op : ops) {
if (!handling.contains(op.id)) {
handling.add(op.id);
arrived.add(op);
}
}
public void onChanged(final List<EntityOperation> operations) {
boolean process = false;
List<Long> current = new ArrayList<>();
for (EntityOperation op : operations) {
if (!handling.contains(op.id))
process = true;
current.add(op.id);
}
handling = current;
if (arrived.size() > 0) {
Log.i(folder.name + " process operations=" + arrived.size());
if (handling.size() > 0 && process) {
Log.i(folder.name + " operations=" + operations.size());
(folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() {
@Override
public void run() {
@ -1230,12 +1229,8 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderError(folder.id, null);
}
processOperations(account, folder, arrived, isession, istore, ifolder, state);
processOperations(account, folder, operations, isession, istore, ifolder, state);
synchronized (handling) {
for (EntityOperation op : arrived)
handling.remove(op.id);
}
} catch (Throwable ex) {
Log.e(folder.name, ex);
reportError(account, folder, ex);
@ -3008,19 +3003,18 @@ public class ServiceSynchronize extends LifecycleService {
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":outbox");
@Override
public void onChanged(final List<EntityOperation> ops) {
final List<EntityOperation> arrived = new ArrayList<>();
synchronized (handling) {
for (EntityOperation op : ops) {
if (!handling.contains(op.id)) {
handling.add(op.id);
arrived.add(op);
}
}
public void onChanged(final List<EntityOperation> operations) {
boolean process = false;
List<Long> current = new ArrayList<>();
for (EntityOperation op : operations) {
if (!handling.contains(op.id))
process = true;
current.add(op.id);
}
handling = current;
if (arrived.size() > 0) {
Log.i(outbox.name + " process operations=" + arrived.size());
if (handling.size() > 0 && process) {
Log.i(outbox.name + " operations=" + operations.size());
executor.submit(new Runnable() {
@Override
public void run() {
@ -3029,13 +3023,8 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(outbox.name + " process");
db.folder().setFolderSyncState(outbox.id, "syncing");
processOperations(null, outbox, arrived, null, null, null, state);
processOperations(null, outbox, operations, null, null, null, state);
db.folder().setFolderError(outbox.id, null);
for (EntityOperation op : arrived)
synchronized (handling) {
handling.remove(op.id);
}
} catch (Throwable ex) {
Log.e(outbox.name, ex);
reportError(null, outbox, ex);