diff --git a/src/activities/browser/OpdsBookBrowserActivity.cpp b/src/activities/browser/OpdsBookBrowserActivity.cpp index f6a58385..259a55da 100644 --- a/src/activities/browser/OpdsBookBrowserActivity.cpp +++ b/src/activities/browser/OpdsBookBrowserActivity.cpp @@ -333,6 +333,20 @@ void OpdsBookBrowserActivity::downloadBook(const OpdsEntry& book) { }); if (result == HttpDownloader::OK) { + FsFile downloadedFile; + if (!Storage.openFileForRead("OPDS", filename, downloadedFile) || downloadedFile.size() == 0) { + LOG_ERR("OPDS", "Downloaded file is empty or unreadable: %s", filename.c_str()); + if (downloadedFile) { + downloadedFile.close(); + } + Storage.remove(filename.c_str()); + state = BrowserState::ERROR; + errorMessage = tr(STR_DOWNLOAD_FAILED); + requestUpdate(); + return; + } + downloadedFile.close(); + LOG_DBG("OPDS", "Download complete: %s", filename.c_str()); // Invalidate any existing cache for this file to prevent stale metadata issues diff --git a/src/network/HttpDownloader.cpp b/src/network/HttpDownloader.cpp index 799b8874..34a39e0c 100644 --- a/src/network/HttpDownloader.cpp +++ b/src/network/HttpDownloader.cpp @@ -179,12 +179,6 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string& return FILE_ERROR; } - if (contentLength == 0 && downloaded == 0) { - LOG_ERR("HTTP", "Download failed: no data received"); - Storage.remove(destPath.c_str()); - return HTTP_ERROR; - } - // Verify download size if known if (contentLength > 0 && downloaded != contentLength) { LOG_ERR("HTTP", "Size mismatch: got %zu, expected %zu", downloaded, contentLength);