use of com.owncloud.android.lib.resources.files.MoveFileRemoteOperation in project android by nextcloud.
the class MoveFileOperation method run.
/**
* Performs the operation.
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
// / 1. check move validity
if (targetParentPath.startsWith(srcPath)) {
return new RemoteOperationResult(ResultCode.INVALID_MOVE_INTO_DESCENDANT);
}
OCFile file = getStorageManager().getFileByPath(srcPath);
if (file == null) {
return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND);
}
// / 2. remote move
String targetPath = targetParentPath + file.getFileName();
if (file.isFolder()) {
targetPath += OCFile.PATH_SEPARATOR;
}
RemoteOperationResult result = new MoveFileRemoteOperation(srcPath, targetPath, false).execute(client);
// / 3. local move
if (result.isSuccess()) {
getStorageManager().moveLocalFile(file, targetPath, targetParentPath);
}
return result;
}
Aggregations