From 3f9c43afb9083f2fdfb328e843c301d280d2fb23 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 31 Jul 2020 15:00:07 +0200 Subject: [PATCH] Fixed a scraping issue where failed image writing was not handled correctly. --- es-app/src/scrapers/Scraper.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index a7e06f315..7cef7222b 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -248,8 +248,8 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, #else std::ofstream stream(filePath, std::ios_base::out | std::ios_base::binary); #endif - if (stream.bad()) { - setError("Failed to open image path to write. Permission error? Disk full?"); + if (!stream || stream.bad()) { + setError("Failed to open path for writing image.\nPermission error?"); return; } @@ -257,14 +257,14 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, stream.write(content.data(), content.length()); stream.close(); if (stream.bad()) { - setError("Failed to save image. Disk full?"); + setError("Failed to save image.\nDisk full?"); return; } // Resize it. if (!resizeImage(filePath, Settings::getInstance()->getInt("ScraperResizeMaxWidth"), Settings::getInstance()->getInt("ScraperResizeMaxHeight"))) { - setError("Error saving resized image. Out of memory? Disk full?"); + setError("Error saving resized image.\nOut of memory? Disk full?"); return; } @@ -365,8 +365,8 @@ void ImageDownloadHandle::update() #else std::ofstream stream(mSavePath, std::ios_base::out | std::ios_base::binary); #endif - if (stream.bad()) { - setError("Failed to open image path to write. Permission error? Disk full?"); + if (!stream || stream.bad()) { + setError("Failed to open path for writing image.\nPermission error?"); return; } @@ -374,13 +374,13 @@ void ImageDownloadHandle::update() stream.write(content.data(), content.length()); stream.close(); if (stream.bad()) { - setError("Failed to save image. Disk full?"); + setError("Failed to save image.\nDisk full?"); return; } // Resize it. if (!resizeImage(mSavePath, mMaxWidth, mMaxHeight)) { - setError("Error saving resized image. Out of memory? Disk full?"); + setError("Error saving resized image.\nOut of memory? Disk full?"); return; }