mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-11-04 04:17:50 +00:00 
			
		
		
		
	Merge branch 'master' into develop
This commit is contained in:
		
						commit
						8261865ff2
					
				@ -247,6 +247,12 @@ public class OwnCloudClient extends HttpClient {
 | 
				
			|||||||
            if (location != null) {
 | 
					            if (location != null) {
 | 
				
			||||||
                Log_OC.d(TAG + " #" + mInstanceNumber,  
 | 
					                Log_OC.d(TAG + " #" + mInstanceNumber,  
 | 
				
			||||||
                		"Location to redirect: " + location.getValue());
 | 
					                		"Location to redirect: " + location.getValue());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Release the connection to avoid reach the max number of connections per host
 | 
				
			||||||
 | 
					                // due to it will be set a different url
 | 
				
			||||||
 | 
					                exhaustResponse(method.getResponseBodyAsStream());
 | 
				
			||||||
 | 
					                method.releaseConnection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                method.setURI(new URI(location.getValue(), true));
 | 
					                method.setURI(new URI(location.getValue(), true));
 | 
				
			||||||
                Header destination = method.getRequestHeader("Destination");
 | 
					                Header destination = method.getRequestHeader("Destination");
 | 
				
			||||||
                if (destination == null) {
 | 
					                if (destination == null) {
 | 
				
			||||||
 | 
				
			|||||||
@ -73,30 +73,17 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected RemoteOperationResult run(OwnCloudClient client) {
 | 
					    protected RemoteOperationResult run(OwnCloudClient client) {
 | 
				
			||||||
        RemoteOperationResult result = null;
 | 
					        RemoteOperationResult result = null;
 | 
				
			||||||
        MkColMethod mkcol = null;
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        boolean noInvalidChars = FileUtils.isValidPath(mRemotePath);
 | 
					        boolean noInvalidChars = FileUtils.isValidPath(mRemotePath);
 | 
				
			||||||
        if (noInvalidChars) {
 | 
					        if (noInvalidChars) {
 | 
				
			||||||
        	try {
 | 
					        	result = createFolder(client);
 | 
				
			||||||
        		mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
 | 
					    		if (!result.isSuccess() && mCreateFullPath && 
 | 
				
			||||||
        		int status =  client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
 | 
					    				RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) {
 | 
				
			||||||
        		if (!mkcol.succeeded() && mkcol.getStatusCode() == HttpStatus.SC_CONFLICT && mCreateFullPath) {
 | 
					    			result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
 | 
				
			||||||
        			result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
 | 
					    			if (result.isSuccess()) {
 | 
				
			||||||
        			status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);    // second (and last) try
 | 
						    			result = createFolder(client);	// second (and last) try
 | 
				
			||||||
        		}
 | 
					    			}
 | 
				
			||||||
 | 
					    		}
 | 
				
			||||||
        	
 | 
					        	
 | 
				
			||||||
        		result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
 | 
					 | 
				
			||||||
        		Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
 | 
					 | 
				
			||||||
        		client.exhaustResponse(mkcol.getResponseBodyAsStream());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        	} catch (Exception e) {
 | 
					 | 
				
			||||||
        		result = new RemoteOperationResult(e);
 | 
					 | 
				
			||||||
        		Log_OC.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        	} finally {
 | 
					 | 
				
			||||||
        		if (mkcol != null)
 | 
					 | 
				
			||||||
        			mkcol.releaseConnection();
 | 
					 | 
				
			||||||
        	}
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
        	result = new RemoteOperationResult(ResultCode.INVALID_CHARACTER_IN_NAME);
 | 
					        	result = new RemoteOperationResult(ResultCode.INVALID_CHARACTER_IN_NAME);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -105,7 +92,28 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) {
 | 
					    private RemoteOperationResult createFolder(OwnCloudClient client) {
 | 
				
			||||||
 | 
					        RemoteOperationResult result = null;
 | 
				
			||||||
 | 
					        MkColMethod mkcol = null;
 | 
				
			||||||
 | 
					    	try {
 | 
				
			||||||
 | 
					    		mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
 | 
				
			||||||
 | 
					    		int status =  client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
 | 
				
			||||||
 | 
					    		result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
 | 
				
			||||||
 | 
					    		Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
 | 
				
			||||||
 | 
					    		client.exhaustResponse(mkcol.getResponseBodyAsStream());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    	} catch (Exception e) {
 | 
				
			||||||
 | 
					    		result = new RemoteOperationResult(e);
 | 
				
			||||||
 | 
					    		Log_OC.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    	} finally {
 | 
				
			||||||
 | 
					    		if (mkcol != null)
 | 
				
			||||||
 | 
					    			mkcol.releaseConnection();
 | 
				
			||||||
 | 
					    	}
 | 
				
			||||||
 | 
					    	return result;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) {
 | 
				
			||||||
        RemoteOperation operation = new CreateRemoteFolderOperation(parentPath,
 | 
					        RemoteOperation operation = new CreateRemoteFolderOperation(parentPath,
 | 
				
			||||||
                                                                mCreateFullPath);
 | 
					                                                                mCreateFullPath);
 | 
				
			||||||
        return operation.execute(client);
 | 
					        return operation.execute(client);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user