mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Add torrents in pause before applying settings to avoid race conditions
- Started to work on a new function to delete torrents permanently that is safer. Not used yet because it is buggy : it works only for simple cases and I'm not sure I can do better right now with the info libtorrent is providing.
This commit is contained in:
parent
8ce1a4c3df
commit
cfacac7dbf
3 changed files with 61 additions and 2 deletions
56
src/misc.h
56
src/misc.h
|
@ -33,6 +33,7 @@
|
|||
#include <QThread>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
// #include "qtorrenthandle.h"
|
||||
using namespace libtorrent;
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
@ -170,6 +171,61 @@ class misc : public QObject{
|
|||
return true;
|
||||
}
|
||||
|
||||
// FIXME: Not used yet because it is buggy
|
||||
// static bool removeTorrentSavePath(QTorrentHandle h) {
|
||||
// bool success = true;
|
||||
// QString savePath = QDir::cleanPath(h.save_path() + QDir::separator());
|
||||
// unsigned int nbFiles = h.num_files();
|
||||
// QDir saveDir(savePath);
|
||||
// // Check how many file there are
|
||||
// if(nbFiles == 1){
|
||||
// // Only one file, not in a folder
|
||||
// QStringList filters;
|
||||
// filters << h.file_at(0);
|
||||
// QFileInfoList files = saveDir.entryInfoList(filters, QDir::Files);
|
||||
// QFileInfo file;
|
||||
// foreach(file, files){
|
||||
// if(file.fileName() == h.file_at(0) && !file.isSymLink()){
|
||||
// if(saveDir.remove(h.file_at(0))){
|
||||
// qDebug("Deleted only file in torrent at %s", (savePath + h.file_at(0)).toUtf8().data());
|
||||
// return true;
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// std::cerr << "Could not delete only file in torrent at " << (savePath + h.file_at(0)).toUtf8().data() << '\n';
|
||||
// return false;
|
||||
// }
|
||||
// QDir subDir(savePath + h.name());
|
||||
// // Torrent has several files in a subFolder
|
||||
// for(unsigned int i=0; i<nbFiles; ++i){
|
||||
// QString fileName = h.file_at(i);
|
||||
// QStringList filters;
|
||||
// filters << fileName;
|
||||
// QFileInfoList files = saveDir.entryInfoList(filters, QDir::Files);
|
||||
// QFileInfo file;
|
||||
// foreach(file, files){
|
||||
// if(file.fileName() == fileName && !file.isSymLink()){
|
||||
// if(!subDir.remove(h.file_at(i))){
|
||||
// success = false;
|
||||
// std::cerr << "Could not delete file in folder at " << (savePath + h.name() + QDir::separator() + h.file_at(i)).toUtf8().data() << '\n';
|
||||
// }else{
|
||||
// qDebug("Deleted file in folder at %s", (savePath + h.name() + QDir::separator() + h.file_at(i)).toUtf8().data());
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// // try to remove topfolder if empty
|
||||
// if(saveDir.rmdir(h.name())){
|
||||
// qDebug("Removed top folder %s", (savePath+h.name()).toUtf8().data());
|
||||
// }else{
|
||||
// std::cerr << "Could not remove top folder " << (savePath+h.name()).toUtf8().data() << ", it was not empty\n";
|
||||
// }
|
||||
// return success;
|
||||
// }
|
||||
|
||||
static QString findFileInDir(QString dir_path, QString fileName) {
|
||||
QDir dir(dir_path);
|
||||
if(dir.exists(fileName)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue