[console] Fix add host in connection manager

The input is being passed as `str` instead of `int`, so added a
conversion only if the string is indeed a decimal number.
In addition, closing the add host popup after adding it.

Closes: https://dev.deluge-torrent.org/ticket/3538
This commit is contained in:
DjLegolas 2022-08-01 20:08:45 +03:00 committed by Calum Lind
parent 38feea0fa4
commit 543fce4f29
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
1 changed files with 3 additions and 1 deletions

View File

@ -127,12 +127,14 @@ class ConnectionManager(BaseMode, PopupsHandler):
def add_host(self, hostname, port, username, password): def add_host(self, hostname, port, username, password):
log.info('Adding host: %s', hostname) log.info('Adding host: %s', hostname)
if port.isdecimal():
port = int(port)
try: try:
self.hostlist.add_host(hostname, port, username, password) self.hostlist.add_host(hostname, port, username, password)
except ValueError as ex: except ValueError as ex:
self.report_message(_('Error adding host'), f'{hostname}: {ex}') self.report_message(_('Error adding host'), f'{hostname}: {ex}')
else: else:
self.update_select_host_popup() self.pop_popup()
def delete_host(self, host_id): def delete_host(self, host_id):
log.info('Deleting host: %s', host_id) log.info('Deleting host: %s', host_id)