Browse Source

Put temp files in .qBittorrent directory. Closes #4462.

adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
cffa729ac5
  1. 1
      src/app/application.cpp
  2. 2
      src/base/net/downloadhandler.cpp
  3. 7
      src/base/utils/fs.cpp
  4. 1
      src/base/utils/fs.h
  5. 3
      src/webui/abstractwebapplication.cpp

1
src/app/application.cpp

@ -629,6 +629,7 @@ void Application::cleanup() @@ -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

2
src/base/net/downloadhandler.cpp

@ -142,7 +142,7 @@ void DownloadHandler::init() @@ -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;

7
src/base/utils/fs.cpp

@ -518,3 +518,10 @@ QString Utils::Fs::cacheLocation() @@ -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;
}

1
src/base/utils/fs.h

@ -67,6 +67,7 @@ namespace Utils @@ -67,6 +67,7 @@ namespace Utils
/* End of Qt4 code */
QString cacheLocation();
QString tempPath();
}
}

3
src/webui/abstractwebapplication.cpp

@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
#include <QTimer>
#include "base/preferences.h"
#include "base/utils/fs.h"
#include "websessiondata.h"
#include "abstractwebapplication.h"
@ -382,7 +383,7 @@ bool AbstractWebApplication::sessionEnd() @@ -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);

Loading…
Cancel
Save