From 47469fe0eed086a2d9c8f09156cf90836d64df8a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 20 Nov 2020 17:09:06 +0100 Subject: Matrix: revert last commit --- src/DownloadUtils.cpp | 2 +- src/Storage.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') 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 +} -- cgit v1.2.3