[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.
This commit is contained in:
Calum Lind 2018-10-19 13:19:56 +01:00
parent 0e69b9199c
commit dcb3dad435

View File

@ -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: