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

Commit 56291c19 authored by narinder Rana's avatar narinder Rana
Browse files

resolve ConcurrentModificationException

parent c2e923f6
Loading
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.FileObserver;
import foundation.e.drive.models.SyncedFileState;
@@ -140,7 +142,11 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
        //if upload is a success
        if( uploadResult.isSuccess() ){

            try {
                FileObserverService.files.remove(file);
            }catch (Exception ex){
                ex.printStackTrace();
            }

            Object data = uploadResult.getSingleData();
            if(data != null){
+6 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.util.Log;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import foundation.e.drive.receivers.ConnectivityReceiver;
import foundation.e.drive.utils.CommonUtils;
@@ -31,7 +32,7 @@ public class FileObserverService extends Service {
    private final static String TAG = FileObserverService.class.getSimpleName();
    RecursiveFileObserver mFileObserver = null;
    private int observerFlag=-1;
    public static List<File> files=new ArrayList<>();
    public static List<File> files=new CopyOnWriteArrayList<>();
    private boolean remoteFileFlag;


@@ -144,7 +145,10 @@ public class FileObserverService extends Service {
                Intent observersServiceIntent = new Intent(getApplicationContext(), foundation.e.drive.services.ObserverService.class);
                Bundle mBundle = new Bundle();
                mBundle.putBoolean("isFileObserverService", true);
                if(files.size()!=0) {
                    mBundle.putByteArray("fileObserverObject", CommonUtils.convertToBytes(new foundation.e.drive.models.FileObserver(files)));
                }

                observersServiceIntent.putExtras(mBundle);
                startService(observersServiceIntent);
            }catch (Exception exception){
+6 −3
Original line number Diff line number Diff line
@@ -259,10 +259,9 @@ public class ObserverService extends Service implements OnRemoteOperationListene
                return;
            }
        } else {
            if (isFileObserverService && null != fileObserverObject) {

                Log.e("TAG", "ObserverService..isFileObserverService...." + isFileObserverService);

            if (isFileObserverService && null != fileObserverObject) {
                Log.i(TAG, "calling observer service from event event with true and files list data");
                //  List<File> files = fileObserverObject.getFiles();
                DbHelper.updateSyncedFolders(mSyncedFolders, this); //@ToDo: maybe do this when all contents will be synced.

@@ -275,6 +274,10 @@ public class ObserverService extends Service implements OnRemoteOperationListene
                // handleLocalFiles(fileObserverObject.getFiles(), fileObserverObject.getSyncedFileStatesList());

            } else {
                Log.i(TAG, "calling observer service with false or files list data null ");
                if(null!=FileObserverService.files){
                    FileObserverService.files.removeAll(FileObserverService.files);
                }
                scanLocalFiles();
            }