From: David A. Velasco Date: Wed, 5 Dec 2012 11:37:19 +0000 (+0100) Subject: Fixed movement of files: parent folder must be created before move; besides, extra... X-Git-Tag: oc-android-1.4.3~80^2~2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/082c11a1e3bf555139072b534c3e1f2b714e62f8?ds=inline;hp=--cc Fixed movement of files: parent folder must be created before move; besides, extra checks to avoid NULL pointers in dialogs --- 082c11a1e3bf555139072b534c3e1f2b714e62f8 diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index 38a4d71d..1be103b6 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -242,12 +242,16 @@ public class UploadFileOperation extends RemoteOperation { } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE fileToMove = originalFile; } - if (!expectedFile.equals(fileToMove) && !fileToMove.renameTo(expectedFile)) { - mFile.setStoragePath(null); // forget the local file - // by now, treat this as a success; the file was uploaded; the user won't like that the local file is not linked, but this should be a veeery rare fail; - // the best option could be show a warning message (but not a fail) - //result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); - //return result; + if (!expectedFile.equals(fileToMove)) { + File expectedFolder = expectedFile.getParentFile(); + expectedFolder.mkdirs(); + if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) { + mFile.setStoragePath(null); // forget the local file + // by now, treat this as a success; the file was uploaded; the user won't like that the local file is not linked, but this should be a veeery rare fail; + // the best option could be show a warning message (but not a fail) + //result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); + //return result; + } } } } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 6f5f54f9..117b0b2d 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -498,8 +498,10 @@ public class OCFileListFragment extends FragmentListView implements EditNameDial getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT); } - mCurrentDialog.dismiss(); - mCurrentDialog = null; + if (mCurrentDialog != null) { + mCurrentDialog.dismiss(); + mCurrentDialog = null; + } } } @@ -515,8 +517,10 @@ public class OCFileListFragment extends FragmentListView implements EditNameDial mTargetFile.setStoragePath(null); mContainerActivity.getStorageManager().saveFile(mTargetFile); } - mCurrentDialog.dismiss(); - mCurrentDialog = null; + if (mCurrentDialog != null) { + mCurrentDialog.dismiss(); + mCurrentDialog = null; + } listDirectory(); mContainerActivity.onTransferStateChanged(mTargetFile, false, false); } @@ -524,8 +528,10 @@ public class OCFileListFragment extends FragmentListView implements EditNameDial @Override public void onCancel(String callerTag) { Log.d(TAG, "REMOVAL CANCELED"); - mCurrentDialog.dismiss(); - mCurrentDialog = null; + if (mCurrentDialog != null) { + mCurrentDialog.dismiss(); + mCurrentDialog = null; + } }