diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-20 17:09:06 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-20 17:09:06 +0100 |
commit | 47469fe0eed086a2d9c8f09156cf90836d64df8a (patch) | |
tree | 870c192d37b8d4aeb61d4a523379fab1d3812dab /src | |
parent | 974d46dbf198ad7d8cd55bb1827f0a74105375de (diff) |
Matrix: revert last commit
Diffstat (limited to 'src')
-rw-r--r-- | src/DownloadUtils.cpp | 2 | ||||
-rw-r--r-- | src/Storage.cpp | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp index dae013d..33b2830 100644 --- a/src/DownloadUtils.cpp +++ b/src/DownloadUtils.cpp @@ -72,7 +72,7 @@ namespace QuickMedia { } } else { DownloadResult download_result = download_to_string(url, result, additional_args, use_tor, use_browser_useragent, error_handler ? false : true); - if(error_handler) + if(download_result == DownloadResult::OK && error_handler) download_result = error_handler(result) ? DownloadResult::OK : DownloadResult::ERR; if(download_result == DownloadResult::OK) { Path media_file_path_tmp(media_file_path.data + ".tmp"); diff --git a/src/Storage.cpp b/src/Storage.cpp index c2f62bd..1e9f206 100644 --- a/src/Storage.cpp +++ b/src/Storage.cpp @@ -124,10 +124,12 @@ namespace QuickMedia { fseek(file, 0, SEEK_SET); result.resize(file_size); - fread(&result[0], 1, file_size, file); + if(fread(&result[0], 1, file_size, file) != (size_t)file_size) { + fclose(file); + return -1; + } - fclose(file); - return 0; + return fclose(file); } int file_get_size(const Path &path, size_t *size) { @@ -283,4 +285,4 @@ namespace QuickMedia { return false; } -}
\ No newline at end of file +} |