From 495e3321e2bb961465da76aaec963995216b33cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Gonz=C3=A1lez?= Date: Tue, 10 Sep 2019 15:24:50 +0200 Subject: [PATCH] Fix folder creation --- .../files/CreateRemoteFolderOperation.java | 10 +++++++++- .../android/lib/resources/files/FileUtils.java | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java index becb85e4..3985ab2c 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java @@ -72,7 +72,15 @@ public class CreateRemoteFolderOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); + RemoteOperationResult result = createFolder(client); + if (!result.isSuccess() && mCreateFullPath && + RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { + result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); + if (result.isSuccess()) { + result = createFolder(client); // second (and last) try + } + } + return result; } private RemoteOperationResult createFolder(OwnCloudClient client) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index fbf5a359..0fb8248a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -66,4 +66,21 @@ public class FileUtils { } return result; } + + /** + * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , + * : , " , | , ? , * + * + * @param fileName + * @return + */ + public static boolean isValidName(String fileName) { + boolean result = true; + + Log_OC.d(TAG, "fileName =======" + fileName); + if (fileName.contains(PATH_SEPARATOR)) { + result = false; + } + return result; + } }