From 1bfc181cb2aec6ed172b8401090bc5b85c6dcd78 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 26 Aug 2007 19:17:50 +0000 Subject: [PATCH] - Better handing of .finished files (bittorrent class level instead of GUI level) --- TODO | 2 +- src/FinishedTorrents.cpp | 5 ----- src/bittorrent.cpp | 8 ++++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 78cb4b169..16a547a4d 100644 --- a/TODO +++ b/TODO @@ -75,7 +75,7 @@ LANGUAGES UPDATED: - Korean *BETA5* beta5->beta6 changelog: -- FEATURE: Split GUI class from download tab +- FEATURE: Split download tab from GUI class and cleaned up code - BUGFIX: Made torrent deletion from hard-drive safer - BUGFIX: Fixed a bug when switching from finished to downloading list - BUGFIX: Showing checking progress for paused torrents too diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 7aee49a10..c105dd873 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -107,10 +107,6 @@ void FinishedTorrents::addTorrent(QString hash){ finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(":/Icons/skin/seeding.png")), Qt::DecorationRole); setRowColor(row, "orange"); } - // Create .finished file - QFile finished_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); - finished_file.open(QIODevice::WriteOnly | QIODevice::Text); - finished_file.close(); // Update the number of finished torrents ++nbFinished; emit finishedTorrentsNumberChanged(nbFinished); @@ -267,7 +263,6 @@ void FinishedTorrents::deleteTorrent(QString hash){ return; } finishedListModel->removeRow(row); - QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); --nbFinished; emit finishedTorrentsNumberChanged(nbFinished); } diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index df1b2fc93..62c8c3ac9 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -232,6 +232,9 @@ bool bittorrent::isFinished(QString hash) const { // Remove the given hash from the list of finished torrents void bittorrent::setUnfinishedTorrent(QString hash) { + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")){ + QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); + } int index = finishedTorrents.indexOf(hash); if(index != -1) { finishedTorrents.removeAt(index); @@ -243,6 +246,11 @@ void bittorrent::setUnfinishedTorrent(QString hash) { // Add the given hash to the list of finished torrents void bittorrent::setFinishedTorrent(QString hash) { + if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { + QFile finished_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); + finished_file.open(QIODevice::WriteOnly | QIODevice::Text); + finished_file.close(); + } if(!finishedTorrents.contains(hash)) { finishedTorrents << hash; }