From c906b50d1120a7e45f71f7c1b5908009cbae715e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 8 Sep 2008 05:42:34 +0000 Subject: [PATCH] Fix add torrent dialog for torrents with only 1 file --- deluge/ui/gtkui/addtorrentdialog.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 345335a5b..134e3a97c 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -201,15 +201,22 @@ class AddTorrentDialog(component.Component): # Get list of files from torrent info files = [] - prefix = "" - if len(metadata["info"]["files"]) > 1: - prefix = metadata["info"]["name"] - - for f in metadata["info"]["files"]: + if metadata["info"].has_key("files"): + prefix = "" + if len(metadata["info"]["files"]) > 1: + prefix = metadata["info"]["name"] + + for f in metadata["info"]["files"]: + files.append({ + 'path': os.path.join(prefix, *f["path"]), + 'size': f["length"], + 'download': True + }) + else: files.append({ - 'path': os.path.join(prefix, *f["path"]), - 'size': f["length"], - 'download': True + "path": metadata["info"]["name"], + "size": metadata["info"]["length"], + "download": True }) name = "%s (%s)" % (metadata["info"]["name"], os.path.split(filename)[-1])