Fix crash on torrent completion

This commit is contained in:
Christophe Dumez
2010-07-23 17:15:47 +00:00
parent a6b1d308c2
commit 4b77bb57ad
4 changed files with 25 additions and 25 deletions

View File

@@ -1999,22 +1999,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
if(appendqBExtension)
appendqBextensionToTorrent(h, false);
#endif
// Move to download directory if necessary
if(!defaultTempPath.isEmpty()) {
// Check if directory is different
const QDir current_dir(h.save_path());
const QDir save_dir(getSavePath(hash));
if(current_dir != save_dir) {
h.move_storage(save_dir.path());
}
}
const bool was_already_seeded = TorrentPersistentData::isSeed(hash);
if(!was_already_seeded) {
h.save_resume_data();
qDebug("Checking if the torrent contains torrent files to download");
// Check if there are torrent files inside
torrent_info::file_iterator it;
for(it = h.get_torrent_info().begin_files(); it != h.get_torrent_info().end_files(); it++) {
for(torrent_info::file_iterator it = h.get_torrent_info().begin_files(); it != h.get_torrent_info().end_files(); it++) {
qDebug("File path: %s", it->path.string().c_str());
const QString torrent_relpath = misc::toQStringU(it->path.string()).replace("\\", "/");
if(torrent_relpath.endsWith(".torrent", Qt::CaseInsensitive)) {
qDebug("Found possible recursive torrent download.");
@@ -2034,6 +2025,15 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
}
}
// Move to download directory if necessary
if(!defaultTempPath.isEmpty()) {
// Check if directory is different
const QDir current_dir(h.save_path());
const QDir save_dir(getSavePath(hash));
if(current_dir != save_dir) {
h.move_storage(save_dir.absolutePath());
}
}
// Recheck if the user asked to
if(Preferences::recheckTorrentsOnCompletion() && !was_already_seeded) {
// Remember finished state