Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1811be1b authored by masensio's avatar masensio
Browse files

Prevent NullPointException when OwncloudVersion is null in CreateRemoteFolderOperation

parent 060ca75f
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -28,12 +28,11 @@ import org.apache.jackrabbit.webdav.client.methods.MkColMethod;

import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.InvalidCharacterExceptionParser;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;

import com.owncloud.android.lib.resources.status.OwnCloudVersion;


/**
@@ -58,7 +57,8 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
     * Constructor
     * 
     * @param remotePath            Full path to the new directory to create in the remote server.
     * @param createFullPath        'True' means that all the ancestor folders should be created if don't exist yet.
     * @param createFullPath        'True' means that all the ancestor folders should be created
     *                              if don't exist yet.
     */
    public CreateRemoteFolderOperation(String remotePath, boolean createFullPath) {
        mRemotePath = remotePath;
@@ -73,8 +73,10 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
    @Override
    protected RemoteOperationResult run(OwnCloudClient client) {
        RemoteOperationResult result = null;
        boolean noInvalidChars = FileUtils.isValidPath(mRemotePath,
                client.getOwnCloudVersion().isVersionWithForbiddenCharacters());
        OwnCloudVersion version = client.getOwnCloudVersion();
        boolean versionWithForbiddenChars =
                (version != null && version.isVersionWithForbiddenCharacters());
        boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars);
        if (noInvalidChars) {
        	result = createFolder(client);
    		if (!result.isSuccess() && mCreateFullPath && 
@@ -105,7 +107,8 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
                Log_OC.d(TAG, mkcol.getResponseBodyAsString());

            } else {
                result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
                result = new RemoteOperationResult(mkcol.succeeded(), status,
                        mkcol.getResponseHeaders());
                Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
            }
            client.exhaustResponse(mkcol.getResponseBodyAsStream());