diff --git a/app/src/main/java/foundation/e/drive/models/SyncWrapper.java b/app/src/main/java/foundation/e/drive/models/SyncWrapper.java index 40b3e3db3c20d28c45911c0d06fc027bdaf97465..6cae2050bc3e510bc12cadbdf9d5e357ef6d8c41 100644 --- a/app/src/main/java/foundation/e/drive/models/SyncWrapper.java +++ b/app/src/main/java/foundation/e/drive/models/SyncWrapper.java @@ -83,7 +83,7 @@ public class SyncWrapper { public boolean equals(Object obj) { if (obj instanceof SyncRequest) { final SyncRequest objRequest = (SyncRequest) obj; - return (objRequest.equals(this.request) && objRequest.getOperationType() == this.request.getOperationType()); + return (objRequest.equals(this.request)); } return super.equals(obj); } diff --git a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java index ed0f2ab9ae1199e1d0ab5c8f22e2ff99eb1fb940..77aa340ed51f270da4e665f90f2be1eb23b77a9c 100644 --- a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java +++ b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java @@ -247,25 +247,14 @@ public class SynchronizationService extends Service implements OnRemoteOperation @Override public void onRemoteOperationFinish(RemoteOperation callerOperation, RemoteOperationResult result) { Timber.i("onRemoteOperationFinish()"); - SyncWrapper callerWrapper = null; - for (Map.Entry keyValue : startedSync.entrySet()) { - if (keyValue.getValue().getRemoteOperation().equals(callerOperation)) { - callerWrapper = keyValue.getValue(); - callerWrapper.setRunning(false); - startWorker(keyValue.getKey()); - break; - } - } - - if (callerWrapper != null) { - updateFailureCounter(callerWrapper.getRequest(), result.isSuccess()); - } - - if (callerOperation instanceof RemoveFileOperation) { - if ( result.isSuccess() ) { - DbHelper.manageSyncedFileStateDB( ( ( RemoveFileOperation ) callerOperation ).getSyncedFileState(), - "DELETE", this); - } + if (callerOperation instanceof RemoveFileOperation && result.isSuccess()) { + DbHelper + .manageSyncedFileStateDB( + ((RemoveFileOperation) callerOperation) + .getSyncedFileState(), + "DELETE", + this + ); } else { final String operationClassName = callerOperation.getClass().getSimpleName(); switch (result.getCode()) { @@ -309,6 +298,17 @@ public class SynchronizationService extends Service implements OnRemoteOperation break; } } + + for (Map.Entry keyValue : startedSync.entrySet()) { + final SyncWrapper wrapper = keyValue.getValue(); + final RemoteOperation wrapperOperation = wrapper.getRemoteOperation(); + if (wrapperOperation != null && wrapperOperation.equals(callerOperation)) { + wrapper.setRunning(false); + updateFailureCounter(wrapper.getRequest(), result.isSuccess()); + startWorker(keyValue.getKey()); + break; + } + } } private void updateFailureCounter(SyncRequest request, boolean success) {