Remove misc::safeRemove(): shouldn't be needed

This commit is contained in:
Christophe Dumez 2012-02-18 12:49:05 +02:00
commit c25586b500
9 changed files with 45 additions and 50 deletions

View file

@ -793,7 +793,7 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) {
// Remove unneeded and incomplete files
foreach(const QString &uneeded_file, uneeded_files) {
qDebug("Removing uneeded file: %s", qPrintable(uneeded_file));
misc::safeRemove(uneeded_file);
QFile::remove(uneeded_file);
const QString parent_folder = misc::branchPath(uneeded_file);
qDebug("Attempt to remove parent folder (if empty): %s", qPrintable(parent_folder));
misc::removeEmptyFolder(parent_folder);
@ -805,7 +805,7 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) {
filters << hash+".*";
const QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
foreach(const QString &file, files) {
misc::safeRemove(torrentBackup.absoluteFilePath(file));
QFile::remove(torrentBackup.absoluteFilePath(file));
}
TorrentPersistentData::deletePersistentData(hash);
// Remove tracker errors
@ -1005,7 +1005,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
addConsoleMessage(QString::fromLocal8Bit(e.what()), "red");
//emit invalidTorrent(from_url);
misc::safeRemove(path);
QFile::remove(path);
}else{
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
QString displayed_path = path;
@ -1019,7 +1019,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
if(fromScanDir) {
// Remove file
misc::safeRemove(path);
QFile::remove(path);
}
return h;
}
@ -1050,7 +1050,8 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
mergeTorrents(h_ex, t);
// Delete file if temporary
if(!from_url.isNull() || fromScanDir) misc::safeRemove(path);
if(!from_url.isNull() || fromScanDir)
QFile::remove(path);
return h;
}
@ -1058,7 +1059,8 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
if(t->num_files() < 1) {
addConsoleMessage(tr("Error: The torrent %1 does not contain any file.").arg(misc::toQStringU(t->name())));
// Delete file if temporary
if(!from_url.isNull() || fromScanDir) misc::safeRemove(path);
if(!from_url.isNull() || fromScanDir)
QFile::remove(path);
return h;
}
@ -1135,7 +1137,8 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Check if it worked
if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle");
if(!from_url.isNull()) misc::safeRemove(path);
if(!from_url.isNull())
QFile::remove(path);
return h;
}
// Remember root folder
@ -1180,7 +1183,8 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
}
// If temporary file, remove it
if(!from_url.isNull() || fromScanDir) misc::safeRemove(path);
if(!from_url.isNull() || fromScanDir)
QFile::remove(path);
// Display console message
if(!from_url.isNull()) {
@ -1496,7 +1500,7 @@ void QBtSession::loadSessionState() {
if(!QFile::exists(state_path)) return;
if(QFile(state_path).size() == 0) {
// Remove empty invalid state file
misc::safeRemove(state_path);
QFile::remove(state_path);
return;
}
#if LIBTORRENT_VERSION_MINOR > 14
@ -1700,7 +1704,7 @@ void QBtSession::saveFastResumeData() {
const QString filepath = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
QFile resume_file(filepath);
if(resume_file.exists())
misc::safeRemove(filepath);
QFile::remove(filepath);
if(!out.empty() && resume_file.open(QIODevice::WriteOnly)) {
resume_file.write(&out[0], out.size());
resume_file.close();
@ -2302,7 +2306,7 @@ void QBtSession::readAlerts() {
const QString filepath = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
QFile resume_file(filepath);
if(resume_file.exists())
misc::safeRemove(filepath);
QFile::remove(filepath);
qDebug("Saving fastresume data in %s", qPrintable(filepath));
vector<char> out;
bencode(back_inserter(out), *p->resume_data);