Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95af410e authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

prevent NPE due to previous commit

parent 7d6f1c72
Loading
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -247,25 +247,9 @@ public class SynchronizationService extends Service implements OnRemoteOperation
    @Override
    public void onRemoteOperationFinish(RemoteOperation callerOperation, RemoteOperationResult result) {
        Timber.i("onRemoteOperationFinish()");
        SyncWrapper callerWrapper = null;
        for (Map.Entry<Integer, SyncWrapper> 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() ) {
        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 +293,17 @@ public class SynchronizationService extends Service implements OnRemoteOperation
                    break;
            }
        }

        for (Map.Entry<Integer, SyncWrapper> 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) {