From 796224d73369e55b278aa1be1a13f357b094e49c Mon Sep 17 00:00:00 2001 From: "Frederik “Freso” S. Olesen" Date: Mon, 6 Aug 2018 12:21:02 +0200 Subject: Add new "Open File" right-click dialog for Downloads This enables the user to directly open the downloaded archived/file which can be useful for e.g., inspection of what's inside or if they need to copy files from inside the archive to somewhere else. Saves a step compared to "Show in Folder" and then opening the file. --- src/downloadmanager.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/downloadmanager.h') diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 136ecf2a..e85c8c81 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -445,6 +445,8 @@ public slots: void visitOnNexus(int index); + void openFile(int index); + void openInDownloadsFolder(int index); void nxmDescriptionAvailable(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID); -- cgit v1.3.1 From 2060df1585fba272213eb08a678ec13f177a45c3 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Sun, 19 Aug 2018 14:58:24 -0500 Subject: Detect errors when writing downloads to disk and cancel download --- src/downloadmanager.cpp | 25 +++++++++++++++++++------ src/downloadmanager.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src/downloadmanager.h') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 150fa12c..1e907b3f 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -804,8 +804,10 @@ void DownloadManager::resumeDownloadInt(int index) if (info->isPausedState() || info->m_State == STATE_PAUSING) { if (info->m_State == STATE_PAUSING) { if (info->m_Output.isOpen()) { - info->m_Output.write(info->m_Reply->readAll()); - setState(info, STATE_PAUSED); + writeData(info); + if (info->m_State == STATE_PAUSING) { + setState(info, STATE_PAUSED); + } } } if ((info->m_Urls.size() == 0) @@ -1362,10 +1364,7 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) void DownloadManager::downloadReadyRead() { try { - DownloadInfo *info = findDownload(this->sender()); - if (info != nullptr) { - info->m_Output.write(info->m_Reply->readAll()); - } + writeData(findDownload(this->sender())); } catch (const std::bad_alloc&) { reportError(tr("Memory allocation error (in processing downloaded data).")); } @@ -1840,3 +1839,17 @@ void DownloadManager::checkDownloadTimeout() } } } + +void DownloadManager::writeData(DownloadInfo *info) +{ + if (info != nullptr) { + qint64 ret = info->m_Output.write(info->m_Reply->readAll()); + if (ret < info->m_Reply->size()) { + setState(info, DownloadState::STATE_CANCELED); + qCritical(QString("Unable to write download \"%2\" to drive (return %1)").arg(ret).arg(info->m_FileName).toLocal8Bit()); + reportError(tr("Unable to write download to drive (return %1).\n" + "Check the drive's available storage.\n\n" + "Canceling download \"%2\"...").arg(ret).arg(info->m_FileName)); + } + } +} \ No newline at end of file diff --git a/src/downloadmanager.h b/src/downloadmanager.h index e85c8c81..4cbe31b7 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -524,6 +524,8 @@ private: static QString getFileTypeString(int fileType); + void writeData(DownloadInfo *info); + private: static const int AUTOMATIC_RETRIES = 3; -- cgit v1.3.1