Fixed lost local copy of file when moved into a folder that is not created in the...
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 1 Sep 2014 08:35:47 +0000 (10:35 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Mon, 1 Sep 2014 08:35:47 +0000 (10:35 +0200)
src/com/owncloud/android/datamodel/FileDataStorageManager.java

index fb57020..aaafb3a 100644 (file)
@@ -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);