From d84461c9b2d11761b1c749442e0f472db8ad9119 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 29 Nov 2016 17:31:14 +0800 Subject: [PATCH 1/2] Remove unused header --- src/base/http/requestparser.cpp | 1 - src/gui/search/pluginselectdlg.cpp | 1 - src/gui/search/searchwidget.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index 70b69bd2a..7f3ab1be7 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -35,7 +35,6 @@ #include #endif #include -#include #include #include "requestparser.h" diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index ecea3068f..97b3cb08a 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #ifdef QBT_USES_QT5 diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 952f1439d..cfc086165 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include From cffa729ac5281474f200a604df0661f010f4272d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 29 Nov 2016 17:55:58 +0800 Subject: [PATCH 2/2] Put temp files in .qBittorrent directory. Closes #4462. --- src/app/application.cpp | 1 + src/base/net/downloadhandler.cpp | 2 +- src/base/utils/fs.cpp | 7 +++++++ src/base/utils/fs.h | 1 + src/webui/abstractwebapplication.cpp | 3 ++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 85bf2de25..98a43ec89 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -629,6 +629,7 @@ void Application::cleanup() delete m_fileLogger; Logger::freeInstance(); IconProvider::freeInstance(); + Utils::Fs::removeDirRecursive(Utils::Fs::tempPath()); #ifndef DISABLE_GUI #ifdef Q_OS_WIN diff --git a/src/base/net/downloadhandler.cpp b/src/base/net/downloadhandler.cpp index b77c59d1e..13142775c 100644 --- a/src/base/net/downloadhandler.cpp +++ b/src/base/net/downloadhandler.cpp @@ -142,7 +142,7 @@ void DownloadHandler::init() bool DownloadHandler::saveToFile(const QByteArray &replyData, QString &filePath) { - QTemporaryFile *tmpfile = new QTemporaryFile; + QTemporaryFile *tmpfile = new QTemporaryFile(Utils::Fs::tempPath() + "XXXXXX"); if (!tmpfile->open()) { delete tmpfile; return false; diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 1a758f755..2b2b32bbc 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -518,3 +518,10 @@ QString Utils::Fs::cacheLocation() locationDir.mkpath(locationDir.absolutePath()); return location; } + +QString Utils::Fs::tempPath() +{ + static const QString path = QDir::tempPath() + "/.qBittorrent/"; + QDir().mkdir(path); + return path; +} diff --git a/src/base/utils/fs.h b/src/base/utils/fs.h index 673845505..f96d9df2b 100644 --- a/src/base/utils/fs.h +++ b/src/base/utils/fs.h @@ -67,6 +67,7 @@ namespace Utils /* End of Qt4 code */ QString cacheLocation(); + QString tempPath(); } } diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index 7e52c134b..5b74f1bd8 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -36,6 +36,7 @@ #include #include "base/preferences.h" +#include "base/utils/fs.h" #include "websessiondata.h" #include "abstractwebapplication.h" @@ -382,7 +383,7 @@ bool AbstractWebApplication::sessionEnd() QString AbstractWebApplication::saveTmpFile(const QByteArray &data) { - QTemporaryFile tmpfile(QDir::temp().absoluteFilePath("qBT-XXXXXX.torrent")); + QTemporaryFile tmpfile(Utils::Fs::tempPath() + "XXXXXX.torrent"); tmpfile.setAutoRemove(false); if (tmpfile.open()) { tmpfile.write(data);