1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Fix folder creation

This commit is contained in:
David González 2019-09-10 15:24:50 +02:00 committed by davigonz
parent 234add959a
commit 495e3321e2
2 changed files with 26 additions and 1 deletions

View File

@ -72,7 +72,15 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
*/ */
@Override @Override
protected RemoteOperationResult run(OwnCloudClient client) { 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) { private RemoteOperationResult createFolder(OwnCloudClient client) {

View File

@ -66,4 +66,21 @@ public class FileUtils {
} }
return result; 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;
}
} }