summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deluge/core/torrent.py5
-rw-r--r--deluge/tests/test_torrentmanager.py10
2 files changed, 14 insertions, 1 deletions
diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index be91b9da5..1676ff6ca 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -266,6 +266,9 @@ class Torrent(object):
self.is_finished = False
self.filename = filename
+ if not self.filename:
+ self.filename = ''
+
self.forced_error = None
self.statusmsg = None
self.state = None
@@ -1316,7 +1319,7 @@ class Torrent(object):
torrent_files = [
os.path.join(get_config_dir(), 'state', self.torrent_id + '.torrent')
]
- if delete_copies:
+ if delete_copies and self.filename:
torrent_files.append(
os.path.join(self.config['torrentfiles_location'], self.filename)
)
diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py
index 5cb201984..20f824eb7 100644
--- a/deluge/tests/test_torrentmanager.py
+++ b/deluge/tests/test_torrentmanager.py
@@ -56,6 +56,16 @@ class TorrentmanagerTestCase(BaseTestCase):
)
self.assertTrue(self.tm.remove(torrent_id, False))
+ @defer.inlineCallbacks
+ def test_remove_magnet(self):
+ """Test remove magnet before received metadata and delete_copies is True"""
+ magnet = 'magnet:?xt=urn:btih:ab570cdd5a17ea1b61e970bb72047de141bce173'
+ options = {}
+ self.core.config.config['copy_torrent_file'] = True
+ self.core.config.config['del_copy_torrent_file'] = True
+ torrent_id = yield self.core.add_torrent_magnet(magnet, options)
+ self.assertTrue(self.tm.remove(torrent_id, False))
+
def test_prefetch_metadata(self):
from deluge._libtorrent import lt