Commit 0cb8b626 authored by narinder Rana's avatar narinder Rana
Browse files

manage Files List before and after upload

parent 764a385c
Pipeline #134250 failed with stage
in 7 seconds
......@@ -25,6 +25,7 @@ import java.io.File;
import java.util.ArrayList;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.SyncedFileState;
import foundation.e.drive.services.InitializerService;
import foundation.e.drive.utils.CommonUtils;
/**
......@@ -136,6 +137,17 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
//if upload is a success
if( uploadResult.isSuccess() ){
Log.e(TAG, "upload is success ........................."+file.getName()
+" "+file.getAbsolutePath());
Log.e(TAG, "files size before remove ........................."+InitializerService.files.size());
InitializerService.files.remove(file);
Log.e(TAG, "files size after remove ........................."+InitializerService.files.size());
Object data = uploadResult.getSingleData();
if(data != null){
mSyncedState.setLastETAG((String) data);
......
......@@ -23,13 +23,15 @@ import java.util.List;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.RecursiveFileObserver;
public class FileObserverService extends Service {
private final static String TAG = FileObserverService.class.getSimpleName();
RecursiveFileObserver mFileObserver = null;
private int observerFlag=-1;
//List<SyncedFileState> syncedFileStatesList=new ArrayList<>();
List<File> files=new ArrayList<>();
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
......@@ -81,7 +83,12 @@ public class FileObserverService extends Service {
// }
// }
// syncedFileStatesList.add(syncedFileStates);
files.add(file);
if(!InitializerService.files.contains(file)){
Log.e(TAG, "adding new file into files list "+file.getName() +" .... "+file.getAbsolutePath());
InitializerService.files.add(file);
}
//Check internet
......@@ -92,7 +99,6 @@ public class FileObserverService extends Service {
try
{
if(observerFlag == -1){
new AsyncTaskRunner().execute("");
}
}
......@@ -152,7 +158,7 @@ public class FileObserverService extends Service {
Bundle mBundle = new Bundle();
mBundle.putBoolean("isFileObserverService", true);
mBundle.putByteArray("fileObserverObject", CommonUtils.convertToBytes(new foundation.e.drive.models.FileObserver(files)));
// mBundle.putByteArray("fileObserverObject", CommonUtils.convertToBytes(new foundation.e.drive.models.FileObserver(files)));
observersServiceIntent.putExtras(mBundle);
startService(observersServiceIntent);
}catch (Exception exception){
......
......@@ -62,6 +62,7 @@ public class InitializerService extends Service
private int restartFolderCreationCounter =0;
private ConnectivityReceiver connectivityReceiver;
public static List<File> files=new ArrayList<>();
// public static List<File> fileObserver=new ArrayList<>();
@Override
......
......@@ -71,7 +71,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
private Account mAccount;
private HashMap<Integer, Parcelable> operationsForIntent;
private Boolean isFileObserverService=false;
private foundation.e.drive.models.FileObserver fileObserverObject;
// private foundation.e.drive.models.FileObserver fileObserverObject;
/* Lifecycle Methods */
@Override
......@@ -89,7 +89,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
Bundle bundle = intent.getExtras();
if(null!=bundle){
isFileObserverService = bundle.getBoolean("isFileObserverService");
fileObserverObject = (foundation.e.drive.models.FileObserver)CommonUtils.convertFromBytes(bundle.getByteArray("fileObserverObject"));
// fileObserverObject = (foundation.e.drive.models.FileObserver)CommonUtils.convertFromBytes(bundle.getByteArray("fileObserverObject"));
}
}catch (Exception ex){
ex.printStackTrace();
......@@ -253,20 +253,15 @@ public class ObserverService extends Service implements OnRemoteOperationListene
}
} else {
if(isFileObserverService){
Log.e("TAG", "isFileObserverService................"+isFileObserverService);
//mSyncedFolders we have here
//we can get getIdsFromFolderToScan
List<File> files = fileObserverObject.getFiles();
// List<File> files = fileObserverObject.getFiles();
DbHelper.updateSyncedFolders(mSyncedFolders, this); //@ToDo: maybe do this when all contents will be synced.
List<SyncedFileState> syncedFileStates = DbHelper.getSyncedFileStatesByFolders(this,
getIdsFromFolderToScan());
if(!syncedFileStates.isEmpty() || !files.isEmpty() ) {
handleLocalFiles(files, syncedFileStates);
if(!syncedFileStates.isEmpty() || !InitializerService.files.isEmpty() ) {
handleLocalFiles(InitializerService.files, syncedFileStates);
}
// handleLocalFiles(fileObserverObject.getFiles(), fileObserverObject.getSyncedFileStatesList());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment