Browse Source

Forgot to use the new safeRemove() function at some places

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
ff08abe177
  1. 18
      src/engineselectdlg.cpp
  2. 2
      src/geoip.h
  3. 4
      src/rss.cpp
  4. 2
      src/torrentadditiondlg.cpp

18
src/engineselectdlg.cpp

@ -265,7 +265,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
if(QFile::exists(dest_path)) { if(QFile::exists(dest_path)) {
// Backup in case install fails // Backup in case install fails
QFile::copy(dest_path, dest_path+".bak"); QFile::copy(dest_path, dest_path+".bak");
QFile::remove(dest_path); misc::safeRemove(dest_path);
update = true; update = true;
} }
// Copy the plugin // Copy the plugin
@ -276,22 +276,22 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
if(!supported_engines->contains(plugin_name)) { if(!supported_engines->contains(plugin_name)) {
if(update) { if(update) {
// Remove broken file // Remove broken file
QFile::remove(dest_path); misc::safeRemove(dest_path);
// restore backup // restore backup
QFile::copy(dest_path+".bak", dest_path); QFile::copy(dest_path+".bak", dest_path);
QFile::remove(dest_path+".bak"); misc::safeRemove(dest_path+".bak");
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name)); QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} else { } else {
// Remove broken file // Remove broken file
QFile::remove(dest_path); misc::safeRemove(dest_path);
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name)); QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} }
} }
// Install was successful, remove backup // Install was successful, remove backup
if(update) { if(update) {
QFile::remove(dest_path+".bak"); misc::safeRemove(dest_path+".bak");
} }
if(update) { if(update) {
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name)); QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name));
@ -409,7 +409,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
// Close file // Close file
versions.close(); versions.close();
// Clean up tmp file // Clean up tmp file
QFile::remove(versions_file); misc::safeRemove(versions_file);
if(file_correct && !updated) { if(file_correct && !updated) {
QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("All your plugins are already up to date.")); QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("All your plugins are already up to date."));
} }
@ -439,21 +439,21 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
} }
} }
// Delete tmp file // Delete tmp file
QFile::remove(filePath); misc::safeRemove(filePath);
return; return;
} }
if(url.endsWith("versions.txt")) { if(url.endsWith("versions.txt")) {
if(!parseVersionsFile(filePath)) { if(!parseVersionsFile(filePath)) {
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable.")); QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
} }
QFile::remove(filePath); misc::safeRemove(filePath);
return; return;
} }
if(url.endsWith(".py", Qt::CaseInsensitive)) { if(url.endsWith(".py", Qt::CaseInsensitive)) {
QString plugin_name = url.split('/').last(); QString plugin_name = url.split('/').last();
plugin_name.replace(".py", ""); plugin_name.replace(".py", "");
installPlugin(filePath, plugin_name); installPlugin(filePath, plugin_name);
QFile::remove(filePath); misc::safeRemove(filePath);
return; return;
} }
} }

2
src/geoip.h

@ -76,7 +76,7 @@ protected:
} }
// Remove destination files // Remove destination files
if(QFile::exists(geoipDBpath(false))) if(QFile::exists(geoipDBpath(false)))
QFile::remove(geoipDBpath(false)); misc::safeRemove(geoipDBpath(false));
// Copy from executable to hard disk // Copy from executable to hard disk
qDebug("%s -> %s", qPrintable(geoipDBpath(true)), qPrintable(geoipDBpath(false))); qDebug("%s -> %s", qPrintable(geoipDBpath(true)), qPrintable(geoipDBpath(false)));
if(!QFile::copy(geoipDBpath(true), geoipDBpath(false))) { if(!QFile::copy(geoipDBpath(true), geoipDBpath(false))) {

4
src/rss.cpp

@ -416,9 +416,9 @@ RssStream::~RssStream(){
removeAllItems(); removeAllItems();
qDebug("All items were removed"); qDebug("All items were removed");
if(QFile::exists(filePath)) if(QFile::exists(filePath))
QFile::remove(filePath); misc::safeRemove(filePath);
if(QFile::exists(iconPath) && !iconPath.startsWith(":/")) if(QFile::exists(iconPath) && !iconPath.startsWith(":/"))
QFile::remove(iconPath); misc::safeRemove(iconPath);
} }
RssFile::FileType RssStream::getType() const { RssFile::FileType RssStream::getType() const {

2
src/torrentadditiondlg.cpp

@ -187,7 +187,7 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
qDebug("Caught error loading torrent"); qDebug("Caught error loading torrent");
if(!from_url.isNull()){ if(!from_url.isNull()){
BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
QFile::remove(filePath); misc::safeRemove(filePath);
}else{ }else{
BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
} }

Loading…
Cancel
Save