Browse Source

Fixed lost local copy of file when moved into a folder that is not created in the local file system yet

David A. Velasco 10 years ago
parent
commit
679c7ed157
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/com/owncloud/android/datamodel/FileDataStorageManager.java

+ 6 - 1
src/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -718,7 +718,12 @@ public class FileDataStorageManager {
             File localFile = new File(localPath);
             boolean renamed = false;
             if (localFile.exists()) {
-                renamed = localFile.renameTo(new File(defaultSavePath + targetPath));
+                File targetFile = new File(defaultSavePath + targetPath);
+                File targetFolder = targetFile.getParentFile();
+                if (!targetFolder.exists()) {
+                    targetFolder.mkdirs();
+                }
+                renamed = localFile.renameTo(targetFile);
             }
             Log_OC.d(TAG, "Local file RENAMED : " + renamed);