mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 00:06:16 -07:00
- Improved debug output
- code clean up - Moved some bittorrent code from GUI class to Bittorrent one
This commit is contained in:
parent
3cb0612cc6
commit
dbc084dd66
3 changed files with 11 additions and 9 deletions
|
@ -675,7 +675,7 @@ void GUI::restoreInDownloadList(torrent_handle h){
|
||||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
||||||
// Pause torrent if it was paused last time
|
// Pause torrent if it was paused last time
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
|
if(BTSession->isPaused(hash)) {
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
|
||||||
setRowColor(row, "red");
|
setRowColor(row, "red");
|
||||||
}else{
|
}else{
|
||||||
|
@ -898,13 +898,9 @@ void GUI::closeEvent(QCloseEvent *e){
|
||||||
// Hide tray icon
|
// Hide tray icon
|
||||||
myTrayIcon->hide();
|
myTrayIcon->hide();
|
||||||
}
|
}
|
||||||
// Save DHT entry
|
|
||||||
BTSession->saveDHTEntry();
|
|
||||||
// Save window size, columns size
|
// Save window size, columns size
|
||||||
writeSettings();
|
writeSettings();
|
||||||
saveColWidthDLList();
|
saveColWidthDLList();
|
||||||
// Create fast resume data
|
|
||||||
BTSession->saveFastResumeData();
|
|
||||||
// Accept exit
|
// Accept exit
|
||||||
e->accept();
|
e->accept();
|
||||||
qApp->exit();
|
qApp->exit();
|
||||||
|
|
|
@ -66,7 +66,12 @@ bittorrent::bittorrent(){
|
||||||
|
|
||||||
// Main destructor
|
// Main destructor
|
||||||
bittorrent::~bittorrent(){
|
bittorrent::~bittorrent(){
|
||||||
|
// Disable directory scanning
|
||||||
disableDirectoryScanning();
|
disableDirectoryScanning();
|
||||||
|
// Do some saving
|
||||||
|
saveDHTEntry();
|
||||||
|
saveFastResumeAndRatioData();
|
||||||
|
// Delete our objects
|
||||||
delete downloader;
|
delete downloader;
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
|
@ -646,8 +651,8 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash){
|
||||||
|
|
||||||
// Save fastresume data for all torrents
|
// Save fastresume data for all torrents
|
||||||
// and remove them from the session
|
// and remove them from the session
|
||||||
void bittorrent::saveFastResumeData(){
|
void bittorrent::saveFastResumeAndRatioData(){
|
||||||
qDebug("Saving fast resume data");
|
qDebug("Saving fast resume and ratio data");
|
||||||
QString file;
|
QString file;
|
||||||
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
// Checking if torrentBackup Dir exists
|
// Checking if torrentBackup Dir exists
|
||||||
|
@ -686,7 +691,7 @@ void bittorrent::saveFastResumeData(){
|
||||||
// Remove torrent
|
// Remove torrent
|
||||||
s->remove_torrent(h);
|
s->remove_torrent(h);
|
||||||
}
|
}
|
||||||
qDebug("Fast resume data saved");
|
qDebug("Fast resume and ratio data saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bittorrent::isFilePreviewPossible(QString hash) const{
|
bool bittorrent::isFilePreviewPossible(QString hash) const{
|
||||||
|
@ -1129,6 +1134,7 @@ void bittorrent::saveDHTEntry(){
|
||||||
boost::filesystem::ofstream out((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
|
boost::filesystem::ofstream out((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||||
|
qDebug("DHT entry saved");
|
||||||
}catch (std::exception& e){
|
}catch (std::exception& e){
|
||||||
std::cerr << e.what() << "\n";
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ class bittorrent : public QObject{
|
||||||
void enableDHT();
|
void enableDHT();
|
||||||
void disableDHT();
|
void disableDHT();
|
||||||
void saveDHTEntry();
|
void saveDHTEntry();
|
||||||
void saveFastResumeData();
|
void saveFastResumeAndRatioData();
|
||||||
void enableDirectoryScanning(QString scan_dir);
|
void enableDirectoryScanning(QString scan_dir);
|
||||||
void disableDirectoryScanning();
|
void disableDirectoryScanning();
|
||||||
void enablePeerExchange();
|
void enablePeerExchange();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue