Browse Source

BUGFIX: Fixed deletion from hard drive (failed for non-empty folders)

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
9f075f5087
  1. 1
      Changelog
  2. 1
      TODO
  3. 7
      src/GUI.cpp
  4. 27
      src/misc.h

1
Changelog

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
- BUGFIX: Fixed download from url that would fail sometimes
- BUGFIX: Save directory was reset to default when filtering files in torrent
- BUGFIX: Force a refresh of download list when the window is shown (avoid delay)
- BUGFIX: Fixed deletion from hard drive (failed for non-empty folders)
- COSMETIC: Replaced OSD messages by systray messages
* Tue Nov 28 2006 - Christophe Dumez <chris@qbittorrent.org> - v0.8.0

1
TODO

@ -37,5 +37,4 @@ @@ -37,5 +37,4 @@
// In v0.9.0
- Wait for libtorrent v0.12 release
- Add an option to disable Peer Exchange (PeX)
- Check deletion from hard drive (bug reported)
- Should create options dialog only when needed to save up some memory

7
src/GUI.cpp

@ -1092,9 +1092,9 @@ void GUI::deletePermanently(){ @@ -1092,9 +1092,9 @@ void GUI::deletePermanently(){
torrentBackup.remove(fileName+".savepath");
// Remove from Hard drive TODO
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
QDir downloadedDir(savePath+QDir::separator()+fileName);
downloadedDir.rmpath(savePath+QDir::separator()+fileName);
QFile::remove(savePath+QDir::separator()+fileName);
if(!misc::removePath(savePath+QDir::separator()+fileName)){
qDebug("Couldn't remove the download on the hard drive");
}
// Update info bar
setInfoBar("'" + fileName +"' "+tr("removed.", "<file> removed."));
--nbTorrents;
@ -1261,6 +1261,7 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_ @@ -1261,6 +1261,7 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, true);
qDebug("Compact allocation mode");
}
// Is this really useful and appropriate ?
//h.set_max_connections(60);
h.set_max_uploads(-1);
// Load filtered files

27
src/misc.h

@ -101,6 +101,33 @@ class misc : public QObject{ @@ -101,6 +101,33 @@ class misc : public QObject{
return qBtPath;
}
static bool removePath(QString path){
if(!QFile::remove(path)){
// Probably a folder
QDir current_dir(path);
if(current_dir.exists()){
//Remove sub items
QStringList subItems = current_dir.entryList();
QString item;
foreach(item, subItems){
if(item != "." && item != ".."){
qDebug("-> Removing "+(path+QDir::separator()+item).toUtf8());
removePath(path+QDir::separator()+item);
}
}
// Remove empty folder
if(current_dir.rmpath(path)){
return true;
}else{
return false;
}
}else{
return false;
}
}
return true;
}
// Function called by curl to write the data to the file
static int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream){
return fwrite(buffer, size, nmemb, (FILE*)stream);

Loading…
Cancel
Save