Delete temporary after they aren't needed. Closes #1188.

This commit is contained in:
sledgehammer999 2014-01-02 22:43:17 +02:00
parent ecfd06cfe9
commit 423d60cced
6 changed files with 12 additions and 5 deletions

View file

@ -134,8 +134,8 @@ void DownloadThread::processDlFinished(QNetworkReply* reply) {
}
// Success
QTemporaryFile *tmpfile = new QTemporaryFile;
tmpfile->setAutoRemove(false);
if (tmpfile->open()) {
tmpfile->setAutoRemove(false);
QString filePath = tmpfile->fileName();
qDebug("Temporary filename is: %s", qPrintable(filePath));
if (reply->isOpen() || reply->open(QIODevice::ReadOnly)) {
@ -153,6 +153,7 @@ void DownloadThread::processDlFinished(QNetworkReply* reply) {
emit downloadFinished(url, filePath);
} else {
delete tmpfile;
fsutils::forceRemove(filePath);
// Error when reading the request
emit downloadFailure(url, tr("I/O Error"));
}

View file

@ -41,6 +41,7 @@
#include "ui_trackersadditiondlg.h"
#include "downloadthread.h"
#include "qtorrenthandle.h"
#include "fs_utils.h"
class TrackersAdditionDlg : public QDialog, private Ui::TrackersAdditionDlg{
Q_OBJECT
@ -79,6 +80,7 @@ public slots:
setCursor(Qt::ArrowCursor);
uTorrentListButton->setEnabled(true);
sender()->deleteLater();
fsutils::forceRemove(path);
return;
}
QList<QUrl> existingTrackers;
@ -113,7 +115,7 @@ public slots:
}
// Clean up
list_file.close();
list_file.remove();
fsutils::forceRemove(path);
//To restore the cursor ...
setCursor(Qt::ArrowCursor);
uTorrentListButton->setEnabled(true);

View file

@ -2704,6 +2704,7 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
h.pause();
emit newDownloadedTorrentFromRss(url);
}
fsutils::forceRemove(file_path);
}
// Return current download rate for the BT

View file

@ -629,6 +629,7 @@ void RSSImp::updateFeedIcon(const QString& url, const QString& iconPath)
{
QTreeWidgetItem* item = m_feedList->getTreeItemFromUrl(url);
item->setData(0, Qt::DecorationRole, QVariant(QIcon(iconPath)));
fsutils::forceRemove(iconPath);
}
void RSSImp::updateFeedInfos(const QString& url, const QString& display_name, uint nbUnread)

View file

@ -30,6 +30,7 @@
#include "rssparser.h"
#include "downloadthread.h"
#include "fs_utils.h"
#include <QDebug>
#include <QFile>
#include <QRegExp>
@ -496,12 +497,13 @@ void RssParser::parseFeed(const ParsingJob& job)
}
// Clean up
QFile::remove(job.filePath);
fileRss.close();
emit feedParsingFinished(job.feedUrl, QString());
fsutils::forceRemove(job.filePath);
}
void RssParser::reportFailure(const ParsingJob& job, const QString& error)
{
QFile::remove(job.filePath);
emit feedParsingFinished(job.feedUrl, error);
fsutils::forceRemove(job.filePath);
}

View file

@ -163,7 +163,7 @@ void SearchEngine::pythonDownloadSuccess(QString url, QString file_path) {
on_search_button_clicked();
}
// Delete temp file
QFile::remove(file_path+".msi");
fsutils::forceRemove(file_path);
}
void SearchEngine::pythonDownloadFailure(QString url, QString error) {