Fix uri handling when dragged to gtk window
This commit is contained in:
parent
d2e1d66f43
commit
00900fef1c
|
@ -85,15 +85,6 @@ class IPCInterface(component.Component):
|
|||
if not os.path.exists(deluge.configmanager.get_config_dir("ipc")):
|
||||
os.makedirs(deluge.configmanager.get_config_dir("ipc"))
|
||||
|
||||
# Make the args absolute paths
|
||||
_args = []
|
||||
for arg in args:
|
||||
if arg.strip():
|
||||
if not deluge.common.is_magnet(arg) and not deluge.common.is_url(arg):
|
||||
arg = os.path.abspath(arg.replace('file://', '', 1))
|
||||
_args.append(arg)
|
||||
args = _args
|
||||
|
||||
socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), "deluge-gtk")
|
||||
|
||||
if deluge.common.windows_check():
|
||||
|
@ -198,7 +189,7 @@ def process_args(args):
|
|||
return
|
||||
config = ConfigManager("gtkui.conf")
|
||||
for arg in args:
|
||||
if not arg:
|
||||
if not arg.strip():
|
||||
continue
|
||||
log.debug("arg: %s", arg)
|
||||
if deluge.common.is_url(arg):
|
||||
|
@ -218,13 +209,14 @@ def process_args(args):
|
|||
client.core.add_torrent_magnet(arg, {})
|
||||
else:
|
||||
# Just a file
|
||||
log.debug("Attempting to add %s from external source..", arg)
|
||||
if not os.path.exists(arg):
|
||||
log.error("No such file: %s", arg)
|
||||
path = os.path.abspath(arg.replace('file://', '', 1))
|
||||
log.debug("Attempting to add %s from external source..", path)
|
||||
if not os.path.exists(path):
|
||||
log.error("No such file: %s", path)
|
||||
continue
|
||||
|
||||
if config["interactive_add"]:
|
||||
component.get("AddTorrentDialog").add_from_files([arg])
|
||||
component.get("AddTorrentDialog").add_from_files([path])
|
||||
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
|
||||
else:
|
||||
client.core.add_torrent_file(os.path.split(arg)[-1], base64.encodestring(open(arg, "rb").read()), None)
|
||||
client.core.add_torrent_file(os.path.split(path)[-1], base64.encodestring(open(path, "rb").read()), None)
|
||||
|
|
|
@ -217,10 +217,7 @@ class MainWindow(component.Component):
|
|||
def on_drag_data_received_event(self, widget, drag_context, x, y, selection_data, info, timestamp):
|
||||
args = []
|
||||
for uri in selection_data.data.split():
|
||||
if deluge.common.windows_check():
|
||||
args.append(urllib.url2pathname(uri[7:]))
|
||||
else:
|
||||
args.append(urllib.unquote(urlparse(uri).path))
|
||||
args.append(urllib.unquote(uri))
|
||||
process_args(args)
|
||||
drag_context.finish(True, True)
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ class QueuedTorrents(component.Component):
|
|||
else:
|
||||
client.core.add_magnet_uris([torrent_path], [])
|
||||
else:
|
||||
torrent_path = os.path.abspath(torrent_path.replace('file://', '', 1))
|
||||
if not os.path.exists(torrent_path):
|
||||
log.error("No such file: %s", torrent_path)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue