Update a download task
@param models\Download\Task $downloadTask
@return models\Download\Task
779243
public function update( models\Download\Task $downloadTask){
        $rest = $this->getService( self::API_DOWNLOAD . $downloadTask->getId());
        $rest->PUT( $downloadTask);

        return $rest->getResult( models\Download\Task::class);
    }
661008
public function attach(Task $task, $task_name = null)
    {
        if (is_null($task_name)) {
            $task_name = count($this->tasks);
        }
        $this->tasks[$task_name] = $task;
        curl_multi_add_handle($this->curl, $task->createCurl());
        $deferred = new Deferred();
        $this->deferred[$task_name] = $deferred;

        return $deferred->promise();
    }
1127392
public static function deliver(Task $task, $bySendMessage = false)
    {
        $task->bySendMessage = $bySendMessage;
        $deliver = function () use ($task, $bySendMessage) {
            /**
             * @var \swoole_http_server $swoole
             */
            $swoole = app('swoole');
            if ($bySendMessage) {
                $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0;
                if ($taskWorkerNum === 0) {
                    throw new \InvalidArgumentException('LaravelS: Asynchronous task needs to set task_worker_num > 0');
                }
                $workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0;
                $totalNum = $workerNum + $taskWorkerNum;

                $getAvailableId = function ($startId, $endId, $excludeId) {
                    $ids = range($startId, $endId);
                    $ids = array_flip($ids);
                    unset($ids[$excludeId]);
                    return array_rand($ids);
                };
                $availableId = $getAvailableId($workerNum, $totalNum - 1, $swoole->worker_id);
                return $swoole->sendMessage($task, $availableId);
            } else {
                $taskId = $swoole->task($task);
                return $taskId !== false;
            }
        };
        if ($task->delay > 0) {
            swoole_timer_after($task->delay * 1000, $deliver);
            return true;
        } else {
            return $deliver();
        }
    }
1166101
public function dispatch(TaskContract $task, array $params = [], bool $async = true, float $timeout = 1)
    {
        $data = ['object' => $task, 'params' => $params];

        return $async ? $this->server->task($data, -1, function (Server $server, int $taskId, $data) use ($task) {
            $task->finish($data);
        }) : $this->server->taskwait($data, $timeout);
    }
1183198
public function updateTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->update($this->tasklist, $task->id, $task);
    }
264072
public function updateFeed(models\Download\Feed\DownloadFeed $downloadFeed)
    {
        $service = sprintf(self::API_DOWNLOAD_FEEDS_ITEM, $downloadFeed->getId());
        $rest    = $this->callService('PUT', $service, $downloadFeed);

        return $rest->getModel(models\Download\Feed\DownloadFeed::class);
    }
1275529
private function updateTask($systemKey, array $systemTask, TaskInterface $task)
    {
        if ($task->getHandlerClass() !== $systemTask['handler_class']
            || $task->getWorkload() !== $systemTask['workload']
        ) {
            throw new \InvalidArgumentException(
                sprintf('No update of handle-class or workload is supported for system-task "%s".', $systemKey)
            );
        }

        if ($task->getInterval() === $systemTask['cron_expression']) {
            return;
        }

        $task->setInterval(CronExpression::factory($systemTask['cron_expression']), $task->getFirstExecution());

        $this->abortPending($task);
        $this->scheduler->scheduleTasks();
    }
1071798
public function task($name, $task = null, $description = null)
    {
        return $this->add($task, $name, $description)->getTask();
    }
1087207
@SuppressWarnings("ResultOfMethodCallIgnored") private void updateSuccess(
      DownloadRequest request) {
    updateState(request, DownloadState.SUCCESSFUL);

    /* notify the request download finish */
    request.finish();

    File file = new File(request.tempFilePath());
    if (file.exists()) {
      file.renameTo(new File(request.destinationFilePath()));
    }

    /* deliver success message */
    delivery.postSuccess(request);
  }
1157559
public function updateTask(Task $task): Task
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use update() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->update($task);
    }
101059
public function add(Task $task) : void
    {
        $this->index++;
        Util::put($this -> storage().$this->index.'.queue', serialize($task));
        $this -> updateIterator();
        Util::put($this -> storage().'_index', $this -> index);
    }
897609
public FileDownloadQueueSet downloadTogether(List<BaseDownloadTask> tasks) {
        this.isSerial = false;
        this.tasks = new BaseDownloadTask[tasks.size()];
        tasks.toArray(this.tasks);

        return this;

    }
1311281
public function download($dest, $callback = null)
    {
        if ($this->isFolder()) {
            return $this->downloadFolder($dest, $callback);
        }

        return $this->downloadFile($dest, $callback);
    }
515555
private function updateTaskLog(WorkPackage $task, $log)
    {
        if ($this->databaseDisabled) {
            return;
        }
        $taskEntity = $task->getTaskEntity();
        if ($taskEntity instanceof Task) {
            $taskEntity->setLog($log);
            //make sure it is stored...
            $this->entityManager->flush($taskEntity);
        } else {
            throw new TaskQueueServiceException("Entity is not of type Task");
        }
    }
877192
public function setConfiguration( models\Download\Config\DownloadConfig $downloadConfig){
        $rest = $this->getService( self::API_DOWNLOAD_CONFIG);
        $rest->PUT( $downloadConfig);

        return $rest->getResult( models\Download\Config\DownloadConfig::class);
    }
981892
public function download($url, $target, $callback = null)
    {
        if (!$this->filesystem->fileExists($target)) {
            $this->filesystem->dirCreate(dir($target));

            $request = new Request($url, $callback ?: function ($response) {
            });

            $request->options['file'] = $target;

            $this->add($request);
        }

        return $this;
    }
702031
public function setConfiguration(models\Download\Config\DownloadConfig $downloadConfig)
    {
        $rest = $this->callService('PUT', self::API_DOWNLOAD_CONFIG, $downloadConfig);

        return $rest->getModel(models\Download\Config\DownloadConfig::class);
    }