From 8d5b0fd73e3b33bafa5c544debadb25047c01247 Mon Sep 17 00:00:00 2001 From: chengzhl Date: Sat, 27 May 2023 11:37:49 +0800 Subject: [PATCH] Handle download error --- src/Downloader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Downloader.cpp b/src/Downloader.cpp index b2e65d4..9ca0eef 100644 --- a/src/Downloader.cpp +++ b/src/Downloader.cpp @@ -159,6 +159,12 @@ void Downloader::setUserAgentString(const QString &agent) void Downloader::finished() { + if (m_reply->error() != QNetworkReply::NoError) + { + QFile::remove(m_downloadDir.filePath(m_fileName + PARTIAL_DOWN)); + return; + } + /* Rename file */ QFile::rename(m_downloadDir.filePath(m_fileName + PARTIAL_DOWN), m_downloadDir.filePath(m_fileName));