mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-09 09:58:39 +00:00
Load .fastresume files on add.
Fix opening browser function.
This commit is contained in:
parent
b645630773
commit
234e6827e8
5 changed files with 30 additions and 19 deletions
|
@ -265,8 +265,7 @@ class Core(dbus.service.Object):
|
||||||
status = self.torrents[torrent_id].get_status(nkeys)
|
status = self.torrents[torrent_id].get_status(nkeys)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# The torrent_id is not found in the torrentmanager, so return None
|
# The torrent_id is not found in the torrentmanager, so return None
|
||||||
status = None
|
return None
|
||||||
return status
|
|
||||||
|
|
||||||
# Get the leftover fields and ask the plugin manager to fill them
|
# Get the leftover fields and ask the plugin manager to fill them
|
||||||
leftover_fields = list(set(nkeys) - set(status.keys()))
|
leftover_fields = list(set(nkeys) - set(status.keys()))
|
||||||
|
|
|
@ -122,6 +122,19 @@ class TorrentManager:
|
||||||
log.warning("Unable to open %s", filename)
|
log.warning("Unable to open %s", filename)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Attempt to load fastresume data
|
||||||
|
try:
|
||||||
|
_file = open(
|
||||||
|
os.path.join(
|
||||||
|
self.config["torrentfiles_location"],
|
||||||
|
filename + ".fastresume"),
|
||||||
|
"rb")
|
||||||
|
fastresume = lt.bdecode(_file.read())
|
||||||
|
_file.close()
|
||||||
|
except IOError:
|
||||||
|
log.debug("Unable to load .fastresume..")
|
||||||
|
fastresume = None
|
||||||
|
|
||||||
# Bdecode the filedata
|
# Bdecode the filedata
|
||||||
torrent_filedump = lt.bdecode(filedump)
|
torrent_filedump = lt.bdecode(filedump)
|
||||||
handle = None
|
handle = None
|
||||||
|
@ -134,7 +147,8 @@ class TorrentManager:
|
||||||
handle = self.session.add_torrent(
|
handle = self.session.add_torrent(
|
||||||
lt.torrent_info(torrent_filedump),
|
lt.torrent_info(torrent_filedump),
|
||||||
self.config["download_location"],
|
self.config["download_location"],
|
||||||
compact)
|
resume_data=fastresume,
|
||||||
|
compact_mode=compact)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
log.warning("Error adding torrent")
|
log.warning("Error adding torrent")
|
||||||
|
|
||||||
|
|
|
@ -177,14 +177,13 @@ def get_listen_port(core=None):
|
||||||
core = get_core()
|
core = get_core()
|
||||||
return int(core.get_listen_port())
|
return int(core.get_listen_port())
|
||||||
|
|
||||||
def open_url_in_browser(link):
|
def open_url_in_browser(url):
|
||||||
"""Opens link in the desktop's default browser"""
|
"""Opens link in the desktop's default browser"""
|
||||||
import threading
|
def start_browser():
|
||||||
import webbrowser
|
import webbrowser
|
||||||
class BrowserThread(threading.Thread):
|
log.debug("Opening webbrowser with url: %s", url)
|
||||||
def __init__(self, link):
|
webbrowser.open(url)
|
||||||
threading.Thread.__init__(self)
|
return False
|
||||||
self.url = link
|
|
||||||
def run(self):
|
import gobject
|
||||||
webbrowser.open(self.url)
|
gobject.idle_add(start_browser)
|
||||||
BrowserThread(link).start()
|
|
||||||
|
|
|
@ -356,7 +356,8 @@ class Preferences:
|
||||||
self.notebook.set_current_page(model.get_value(row, 0))
|
self.notebook.set_current_page(model.get_value(row, 0))
|
||||||
|
|
||||||
def on_test_port_clicked(self, data):
|
def on_test_port_clicked(self, data):
|
||||||
functions.open_url_in_browser('\
|
log.debug("on_test_port_clicked")
|
||||||
http://www.deluge-torrent.org/test-port.php?port=%s' % \
|
url = "http://deluge-torrent.org/test-port.php?port=%s" % \
|
||||||
functions.get_listen_port(self.core))
|
functions.get_listen_port(self.core)
|
||||||
|
functions.open_url_in_browser(url)
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,6 @@ class SystemTray:
|
||||||
self.config = ConfigManager("gtkui.conf")
|
self.config = ConfigManager("gtkui.conf")
|
||||||
self.config.register_set_function("enable_system_tray",
|
self.config.register_set_function("enable_system_tray",
|
||||||
self.on_enable_system_tray_set)
|
self.on_enable_system_tray_set)
|
||||||
#if self.config["enable_system_tray"]:
|
|
||||||
# self.enable()
|
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
"""Enables the system tray icon."""
|
"""Enables the system tray icon."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue