From dcb3dad4356a8d3ba807f7306bb56c170ace1eca Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 19 Oct 2018 13:19:56 +0100 Subject: [PATCH] [Core] Fix renaming folder not updating torrent name The new get_name method needs to function as it did in 1.3-stable so when renaming a torrent file or top-level folder update torrent name to reflect that. If UI supports renaming the torrent then the options value with be used instead. --- deluge/core/torrent.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 7ff0091ff..12b30a45c 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -933,7 +933,16 @@ class Torrent(object): """ if not self.options['name']: - handle_name = self.handle.name() + # Use the top-level folder as torrent name. + if self.has_metadata: + handle_name = ( + self.torrent_info.file_at(0) + .path.replace('\\', '/', 1) + .split('/', 1)[0] + ) + else: + handle_name = self.handle.name() + if handle_name: name = decode_bytes(handle_name) else: