diff --git a/src/GUI.cpp b/src/GUI.cpp index 67631b3fa..38f663428 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -675,7 +675,7 @@ void GUI::restoreInDownloadList(torrent_handle h){ DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); // 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); setRowColor(row, "red"); }else{ @@ -898,13 +898,9 @@ void GUI::closeEvent(QCloseEvent *e){ // Hide tray icon myTrayIcon->hide(); } - // Save DHT entry - BTSession->saveDHTEntry(); // Save window size, columns size writeSettings(); saveColWidthDLList(); - // Create fast resume data - BTSession->saveFastResumeData(); // Accept exit e->accept(); qApp->exit(); diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 7c197f4af..71423f074 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -66,7 +66,12 @@ bittorrent::bittorrent(){ // Main destructor bittorrent::~bittorrent(){ + // Disable directory scanning disableDirectoryScanning(); + // Do some saving + saveDHTEntry(); + saveFastResumeAndRatioData(); + // Delete our objects delete downloader; delete s; } @@ -646,8 +651,8 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash){ // Save fastresume data for all torrents // and remove them from the session -void bittorrent::saveFastResumeData(){ - qDebug("Saving fast resume data"); +void bittorrent::saveFastResumeAndRatioData(){ + qDebug("Saving fast resume and ratio data"); QString file; QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); // Checking if torrentBackup Dir exists @@ -686,7 +691,7 @@ void bittorrent::saveFastResumeData(){ // Remove torrent s->remove_torrent(h); } - qDebug("Fast resume data saved"); + qDebug("Fast resume and ratio data saved"); } 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); out.unsetf(std::ios_base::skipws); bencode(std::ostream_iterator(out), dht_state); + qDebug("DHT entry saved"); }catch (std::exception& e){ std::cerr << e.what() << "\n"; } diff --git a/src/bittorrent.h b/src/bittorrent.h index 8cb558181..3e662604b 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -93,7 +93,7 @@ class bittorrent : public QObject{ void enableDHT(); void disableDHT(); void saveDHTEntry(); - void saveFastResumeData(); + void saveFastResumeAndRatioData(); void enableDirectoryScanning(QString scan_dir); void disableDirectoryScanning(); void enablePeerExchange();