aboutsummaryrefslogtreecommitdiff
path: root/src/DownloadUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DownloadUtils.cpp')
-rw-r--r--src/DownloadUtils.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index cbdded6..2a3f9d3 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -52,7 +52,7 @@ namespace QuickMedia {
return DownloadResult::OK;
}
- DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent) {
+ DownloadResult download_to_string_cache(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor, bool use_browser_useragent, DownloadErrorHandler error_handler) {
Path media_dir = get_cache_dir().join("media");
Path media_file_path = Path(media_dir).join(base64_url::encode(url));
if(get_file_type(media_file_path) == FileType::REGULAR) {
@@ -64,7 +64,9 @@ namespace QuickMedia {
return DownloadResult::ERR;
}
} else {
- DownloadResult download_result = download_to_string(url, result, additional_args, use_tor, use_browser_useragent);
+ DownloadResult download_result = download_to_string(url, result, additional_args, use_tor, use_browser_useragent, error_handler ? false : true);
+ if(!error_handler(result))
+ download_result = DownloadResult::ERR;
if(download_result == DownloadResult::OK) {
Path media_file_path_tmp(media_file_path.data + ".tmp");
if(create_directory_recursive(media_dir) == 0 && file_overwrite(media_file_path_tmp, result) == 0) {