| 177 | } |
| 178 | |
| 179 | void GitHubFileListProvider::download_dictionary(const std::wstring &aff_filepath, const std::wstring &target_path, |
| 180 | std::shared_ptr<ProgressData> progress_data) { |
| 181 | m_download_file_task.do_deferred( |
| 182 | [=, settings_data = m_settings.data](Concurrency::cancellation_token token) -> DownloadResult { |
| 183 | std::vector<std::wstring> downloaded_filenames; |
| 184 | bool cancelled = false; |
| 185 | try { |
| 186 | auto ret = download_dictionary_impl(token, aff_filepath, target_path, progress_data, downloaded_filenames, settings_data, cancelled); |
| 187 | if (ret) { |
| 188 | for (auto &file_name : downloaded_filenames) |
| 189 | WinApi::delete_file(file_name.c_str()); |
| 190 | } |
| 191 | return {ret, cancelled}; |
| 192 | } catch (const std::exception &err) { |
| 193 | for (auto &file_name : downloaded_filenames) |
| 194 | WinApi::delete_file(file_name.c_str()); |
| 195 | return {err.what(), false}; |
| 196 | } |
| 197 | }, |
| 198 | [this](DownloadResult result) { file_downloaded(result.mb_error_description, result.was_cancelled); }); |
| 199 | } |
| 200 | |
| 201 | void GitHubFileListProvider::cancel_download() { m_download_file_task.cancel(); } |
no test coverage detected