| 156 | } |
| 157 | |
| 158 | std::shared_ptr<DownloadTask> Downloader::createDownloadFileTask(std::string_view srcUrl, |
| 159 | std::string_view storagePath, |
| 160 | std::string_view identifier, |
| 161 | std::string_view md5checksum, |
| 162 | bool background, |
| 163 | std::string_view cacertPath) |
| 164 | { |
| 165 | auto task = std::make_shared<DownloadTask>(srcUrl, storagePath, md5checksum, identifier, background, cacertPath); |
| 166 | do |
| 167 | { |
| 168 | if (srcUrl.empty() || storagePath.empty()) |
| 169 | { |
| 170 | if (onTaskError) |
| 171 | { |
| 172 | onTaskError(*task, DownloadTask::ERROR_INVALID_PARAMS, 0, "URL or storage path is empty."); |
| 173 | } |
| 174 | task.reset(); |
| 175 | break; |
| 176 | } |
| 177 | _impl->startTask(task); |
| 178 | } while (0); |
| 179 | |
| 180 | return task; |
| 181 | } |
| 182 | |
| 183 | // std::string Downloader::getFileNameFromUrl(std::string_view srcUrl) |
| 184 | //{ |