diff --git a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java index b047c955862dfded41db1cc7764aa8b1e45922e0..91463c3c49026be15a5f70e88ed23e3edc2812aa 100644 --- a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java +++ b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java @@ -153,7 +153,10 @@ public class FileEventListener { SyncedFolder folder = DbHelper.getSyncedFolderByLocalPath(fileLocalPath, appContext); if (folder == null) { //look for parent - final String parentPath = CommonUtils.getLocalPath(directory.getParentFile()); + final File parentFile = directory.getParentFile(); + if (parentFile == null) return; + + final String parentPath = CommonUtils.getLocalPath(parentFile); final SyncedFolder parentFolder = DbHelper.getSyncedFolderByLocalPath(parentPath, appContext); if (parentFolder == null ) { //if parent is not in the DB return; @@ -200,7 +203,8 @@ public class FileEventListener { Timber.d("New File %s observed but impossible to insert it in DB", file.getName()); } } else { //File update - if (fileState.getScannable() > 1) { + final boolean isWaitingForDownload = fileState.isLastEtagStored() && fileState.getLocalLastModified() == 0L; + if (fileState.getScannable() > 1 && !isWaitingForDownload) { request = new SyncRequest(fileState, UPLOAD); } }