} 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;
+ }
}
}
}
getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
}
- mCurrentDialog.dismiss();
- mCurrentDialog = null;
+ if (mCurrentDialog != null) {
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
+ }
}
}
mTargetFile.setStoragePath(null);
mContainerActivity.getStorageManager().saveFile(mTargetFile);
}
- mCurrentDialog.dismiss();
- mCurrentDialog = null;
+ if (mCurrentDialog != null) {
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
+ }
listDirectory();
mContainerActivity.onTransferStateChanged(mTargetFile, false, false);
}
@Override
public void onCancel(String callerTag) {
Log.d(TAG, "REMOVAL CANCELED");
- mCurrentDialog.dismiss();
- mCurrentDialog = null;
+ if (mCurrentDialog != null) {
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
+ }
}