Commit 764a385c authored by narinder Rana's avatar narinder Rana
Browse files

manage HandleLocalFiles function values

parent 7ae2731f
Pipeline #133911 failed with stage
in 1 minute and 28 seconds
......@@ -8,11 +8,11 @@ public class FileObserver implements Serializable {
private List<File> files;
private List<SyncedFileState> syncedFileStatesList;
//private List<SyncedFileState> syncedFileStatesList;
public FileObserver(List<File> files, List<SyncedFileState> syncedFileStatesList) {
public FileObserver(List<File> files) {
this.files = files;
this.syncedFileStatesList = syncedFileStatesList;
}
public List<File> getFiles() {
......@@ -23,11 +23,11 @@ public class FileObserver implements Serializable {
this.files = files;
}
public List<SyncedFileState> getSyncedFileStatesList() {
return syncedFileStatesList;
}
public void setSyncedFileStatesList(List<SyncedFileState> syncedFileStatesList) {
this.syncedFileStatesList = syncedFileStatesList;
}
// public List<SyncedFileState> getSyncedFileStatesList() {
// return syncedFileStatesList;
// }
//
// public void setSyncedFileStatesList(List<SyncedFileState> syncedFileStatesList) {
// this.syncedFileStatesList = syncedFileStatesList;
// }
}
......@@ -20,17 +20,15 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.SyncedFileState;
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<SyncedFileState> syncedFileStatesList=new ArrayList<>();
List<File> files=new ArrayList<>();
@Override
......@@ -60,15 +58,29 @@ public class FileObserverService extends Service {
//Modify =2, create =256, delete =512, movedTo =128
if(event== FileObserver.CREATE || event==FileObserver.MODIFY || event== FileObserver.DELETE || event ==FileObserver.MOVED_TO){
Log.d("OnEvent", "...Event ..." + event+"...file ..." + file);
Log.e("OnEvent", "...Event ..." + event+"...file ..." + file);
//getting null
SyncedFileState syncedFileStates = DbHelper.loadSyncedFile(getApplicationContext(), file.getPath(), true);
if(null!=syncedFileStates){
syncedFileStatesList.add(syncedFileStates);
}
//
// SyncedFileState syncedFileStates = DbHelper.loadSyncedFile(getApplicationContext(), file.getPath(), true);
//
// if(null==syncedFileStates){
// syncedFileStates = new SyncedFileState(-1, file.getName(), file.getPath(), file.getRemoteFolder() + localFile.getName(), "", 0, syncedFolder.getId(), syncedFolder.isMediaType());
//
// //Store it in DB
// int storedId = DbHelper.manageSyncedFileStateDB(newSyncedFileState, "INSERT", this);
// if(storedId > 0){
// newSyncedFileState.setId( storedId );
// Log.i(TAG, "Add upload operation for new file "+storedId);
// //create UploadOperation and add it into bundle
// UploadFileOperation uploadOperation = new UploadFileOperation(newSyncedFileState, syncedFolder.isScanRemote());
// this.operationsForIntent.put(storedId, uploadOperation);
// }else{
// Log.w(TAG, "The new file to synced cannot be store in DB. Ignore it");
// }
// }
// syncedFileStatesList.add(syncedFileStates);
files.add(file);
//Check internet
......@@ -140,7 +152,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, syncedFileStatesList)));
mBundle.putByteArray("fileObserverObject", CommonUtils.convertToBytes(new foundation.e.drive.models.FileObserver(files)));
observersServiceIntent.putExtras(mBundle);
startService(observersServiceIntent);
}catch (Exception exception){
......
......@@ -254,7 +254,22 @@ public class ObserverService extends Service implements OnRemoteOperationListene
} else {
if(isFileObserverService){
Log.e("TAG", "isFileObserverService................"+isFileObserverService);
handleLocalFiles(fileObserverObject.getFiles(), fileObserverObject.getSyncedFileStatesList());
//mSyncedFolders we have here
//we can get getIdsFromFolderToScan
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);
}
// handleLocalFiles(fileObserverObject.getFiles(), fileObserverObject.getSyncedFileStatesList());
}else {
scanLocalFiles();
......@@ -640,6 +655,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
if(contentToSyncFound) {
DbHelper.updateSyncedFolders(mSyncedFolders, this); //@ToDo: maybe do this when all contents will be synced.
List<SyncedFileState> syncedFileStates = DbHelper.getSyncedFileStatesByFolders(this,
folderIdList);
......
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