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

Commit 6f760e53 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch '5991-fix-uploadAfterDownload' into 'v1-oreo'

Prevent upload of a file after it has been downloaded

See merge request !176
parents 60d10b1f 3bca0d3c
Loading
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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);
            }
        }