From ee75786e4047c750ecf26f04746cb92df42999cc Mon Sep 17 00:00:00 2001 From: Nick Lanham Date: Thu, 24 Feb 2011 12:08:42 +0100 Subject: [PATCH] handle the case where libtorrent doesn't know what files are in a torrent. this is the case when torrent was added by a magnet link --- deluge/ui/console/modes/torrentdetail.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py index 646e00b02..4c5d41e84 100644 --- a/deluge/ui/console/modes/torrentdetail.py +++ b/deluge/ui/console/modes/torrentdetail.py @@ -123,9 +123,12 @@ class TorrentDetail(BaseMode, component.Component): log.debug("got state") if not self.file_list: # don't keep getting the files once we've got them once - self.files_sep = "{!green,black,bold,underline!}%s"%(("Files (torrent has %d files)"%len(state["files"])).center(self.cols)) - self.file_list,self.file_dict = self.build_file_list(state["files"],state["file_progress"],state["file_priorities"]) - self._status_keys.remove("files") + if state.get("files"): + self.files_sep = "{!green,black,bold,underline!}%s"%(("Files (torrent has %d files)"%len(state["files"])).center(self.cols)) + self.file_list,self.file_dict = self.build_file_list(state["files"],state["file_progress"],state["file_priorities"]) + self._status_keys.remove("files") + else: + self.files_sep = "{!green,black,bold,underline!}%s"%(("Files (File list unknown)").center(self.cols)) self._fill_progress(self.file_list,state["file_progress"]) for i,prio in enumerate(state["file_priorities"]): self.file_dict[i][6] = prio @@ -187,6 +190,7 @@ class TorrentDetail(BaseMode, component.Component): # fills in progress fields in all entries based on progs # returns the # of bytes complete in all the children of fs def _fill_progress(self,fs,progs): + if not progs: return 0 tb = 0 for f in fs: if f[3]: # dir, has some children