mirror of https://github.com/M66B/FairEmail.git
Revert "Process newly arrived operations only"
This reverts commit cb1ded8ecf
.
This commit is contained in:
parent
cb1ded8ecf
commit
7ddcc119e6
|
@ -1189,19 +1189,18 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
|
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(final List<EntityOperation> ops) {
|
public void onChanged(final List<EntityOperation> operations) {
|
||||||
final List<EntityOperation> arrived = new ArrayList<>();
|
boolean process = false;
|
||||||
synchronized (handling) {
|
List<Long> current = new ArrayList<>();
|
||||||
for (EntityOperation op : ops) {
|
for (EntityOperation op : operations) {
|
||||||
if (!handling.contains(op.id)) {
|
if (!handling.contains(op.id))
|
||||||
handling.add(op.id);
|
process = true;
|
||||||
arrived.add(op);
|
current.add(op.id);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
handling = current;
|
||||||
|
|
||||||
if (arrived.size() > 0) {
|
if (handling.size() > 0 && process) {
|
||||||
Log.i(folder.name + " process operations=" + arrived.size());
|
Log.i(folder.name + " operations=" + operations.size());
|
||||||
(folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() {
|
(folder.poll ? pollExecutor : folderExecutor).submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -1230,12 +1229,8 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
db.folder().setFolderError(folder.id, null);
|
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) {
|
} catch (Throwable ex) {
|
||||||
Log.e(folder.name, ex);
|
Log.e(folder.name, ex);
|
||||||
reportError(account, folder, ex);
|
reportError(account, folder, ex);
|
||||||
|
@ -3008,19 +3003,18 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":outbox");
|
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":outbox");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(final List<EntityOperation> ops) {
|
public void onChanged(final List<EntityOperation> operations) {
|
||||||
final List<EntityOperation> arrived = new ArrayList<>();
|
boolean process = false;
|
||||||
synchronized (handling) {
|
List<Long> current = new ArrayList<>();
|
||||||
for (EntityOperation op : ops) {
|
for (EntityOperation op : operations) {
|
||||||
if (!handling.contains(op.id)) {
|
if (!handling.contains(op.id))
|
||||||
handling.add(op.id);
|
process = true;
|
||||||
arrived.add(op);
|
current.add(op.id);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
handling = current;
|
||||||
|
|
||||||
if (arrived.size() > 0) {
|
if (handling.size() > 0 && process) {
|
||||||
Log.i(outbox.name + " process operations=" + arrived.size());
|
Log.i(outbox.name + " operations=" + operations.size());
|
||||||
executor.submit(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -3029,13 +3023,8 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
Log.i(outbox.name + " process");
|
Log.i(outbox.name + " process");
|
||||||
|
|
||||||
db.folder().setFolderSyncState(outbox.id, "syncing");
|
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);
|
db.folder().setFolderError(outbox.id, null);
|
||||||
|
|
||||||
for (EntityOperation op : arrived)
|
|
||||||
synchronized (handling) {
|
|
||||||
handling.remove(op.id);
|
|
||||||
}
|
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(outbox.name, ex);
|
Log.e(outbox.name, ex);
|
||||||
reportError(null, outbox, ex);
|
reportError(null, outbox, ex);
|
||||||
|
|
Loading…
Reference in New Issue