From 00d4f6141f22641a5e7894e79336d9a86fbd946b Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Tue, 17 Jan 2017 22:55:01 +0100 Subject: [PATCH] Do not remove added files unconditionally. Closes #6248 If removing of added torrents is enabled and dialog for adding torrents is disabled, file guard was assuming that torrent is added successfully. And that can be not the case if a user trying to add a broken torrent file (or not a torrent file at all). Then this file gets deleted always. Fix this by checking result of addTorrent_impl(). --- src/base/bittorrent/session.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 584ceea65..6ef664e6f 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1576,8 +1576,10 @@ bool Session::addTorrent(QString source, const AddTorrentParams ¶ms) } else { TorrentFileGuard guard(source); - guard.markAsAddedToSession(); - return addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source)); + if (addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source))) { + guard.markAsAddedToSession(); + return true; + } } return false;