Search in sources :

Example 1 with CopyRemoteFileOperation

use of com.owncloud.android.lib.resources.files.CopyRemoteFileOperation in project android by owncloud.

the class CopyFileOperation method run.

/**
     * Performs the operation.
     *
     * @param client Client object to communicate with the remote ownCloud server.
     */
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    RemoteOperationResult result;
    /// 1. check copy validity
    if (mTargetParentPath.startsWith(mSrcPath)) {
        return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT);
    }
    mFile = getStorageManager().getFileByPath(mSrcPath);
    if (mFile == null) {
        return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND);
    }
    /// 2. remote copy
    String targetPath = mTargetParentPath + mFile.getFileName();
    if (mFile.isFolder()) {
        targetPath += OCFile.PATH_SEPARATOR;
    }
    CopyRemoteFileOperation operation = new CopyRemoteFileOperation(mSrcPath, targetPath, false);
    result = operation.execute(client);
    /// 3. local copy
    if (result.isSuccess()) {
        getStorageManager().copyLocalFile(mFile, targetPath);
    }
    return result;
}
Also used : CopyRemoteFileOperation(com.owncloud.android.lib.resources.files.CopyRemoteFileOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Aggregations

RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)1 CopyRemoteFileOperation (com.owncloud.android.lib.resources.files.CopyRemoteFileOperation)1