Browse Source

Normalize local target path in auto upload

This closes #2131 and closes #4220.
Stephan Ritscher 5 years ago
parent
commit
5c387fac7a
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/main/java/com/owncloud/android/utils/FileStorageUtils.java

+ 2 - 1
src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -172,7 +172,8 @@ public final class FileStorageUtils {
             subPath = getSubPathFromDate(dateTaken, current);
         }
 
-        return remotePath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName);
+        /* Path must be normalized; otherwise the next RefreshFolderOperation has a mismatch and deletes the local file. */
+        return (remotePath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName)).replaceAll(OCFile.PATH_SEPARATOR + "+", OCFile.PATH_SEPARATOR);
     }