mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-27 11:45:44 +00:00
Load .fastresume files on add.
Fix opening browser function.
This commit is contained in:
parent
b645630773
commit
234e6827e8
@ -265,8 +265,7 @@ class Core(dbus.service.Object):
|
||||
status = self.torrents[torrent_id].get_status(nkeys)
|
||||
except KeyError:
|
||||
# The torrent_id is not found in the torrentmanager, so return None
|
||||
status = None
|
||||
return status
|
||||
return None
|
||||
|
||||
# Get the leftover fields and ask the plugin manager to fill them
|
||||
leftover_fields = list(set(nkeys) - set(status.keys()))
|
||||
|
@ -121,7 +121,20 @@ class TorrentManager:
|
||||
except IOError:
|
||||
log.warning("Unable to open %s", filename)
|
||||
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
|
||||
torrent_filedump = lt.bdecode(filedump)
|
||||
handle = None
|
||||
@ -134,7 +147,8 @@ class TorrentManager:
|
||||
handle = self.session.add_torrent(
|
||||
lt.torrent_info(torrent_filedump),
|
||||
self.config["download_location"],
|
||||
compact)
|
||||
resume_data=fastresume,
|
||||
compact_mode=compact)
|
||||
except RuntimeError:
|
||||
log.warning("Error adding torrent")
|
||||
|
||||
|
@ -177,14 +177,13 @@ def get_listen_port(core=None):
|
||||
core = get_core()
|
||||
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"""
|
||||
import threading
|
||||
import webbrowser
|
||||
class BrowserThread(threading.Thread):
|
||||
def __init__(self, link):
|
||||
threading.Thread.__init__(self)
|
||||
self.url = link
|
||||
def run(self):
|
||||
webbrowser.open(self.url)
|
||||
BrowserThread(link).start()
|
||||
def start_browser():
|
||||
import webbrowser
|
||||
log.debug("Opening webbrowser with url: %s", url)
|
||||
webbrowser.open(url)
|
||||
return False
|
||||
|
||||
import gobject
|
||||
gobject.idle_add(start_browser)
|
||||
|
@ -356,7 +356,8 @@ class Preferences:
|
||||
self.notebook.set_current_page(model.get_value(row, 0))
|
||||
|
||||
def on_test_port_clicked(self, data):
|
||||
functions.open_url_in_browser('\
|
||||
http://www.deluge-torrent.org/test-port.php?port=%s' % \
|
||||
functions.get_listen_port(self.core))
|
||||
log.debug("on_test_port_clicked")
|
||||
url = "http://deluge-torrent.org/test-port.php?port=%s" % \
|
||||
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.register_set_function("enable_system_tray",
|
||||
self.on_enable_system_tray_set)
|
||||
#if self.config["enable_system_tray"]:
|
||||
# self.enable()
|
||||
|
||||
def enable(self):
|
||||
"""Enables the system tray icon."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user