From: David A. Velasco Date: Mon, 1 Sep 2014 08:35:47 +0000 (+0200) Subject: Fixed lost local copy of file when moved into a folder that is not created in the... X-Git-Tag: oc-android-1.7.0_signed~197^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/679c7ed1576c4db0a4163729ec9471f8124a4abe?ds=inline;hp=-c Fixed lost local copy of file when moved into a folder that is not created in the local file system yet --- 679c7ed1576c4db0a4163729ec9471f8124a4abe diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index fb570203..aaafb3a0 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/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);