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/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/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 5bc3c23c4..a3733c2b5 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -491,3 +491,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 c58b8e89b..3ee9fec5a 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/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 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);