From 4a7782af2844c13e51fbdeedfff452f55ce33647 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 22 Feb 2010 17:11:53 -0800 Subject: [PATCH] Fix #1143 deluge-console crashes when autocompleting non-existing directory --- deluge/ui/console/commands/add.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/deluge/ui/console/commands/add.py b/deluge/ui/console/commands/add.py index 1a931e4d1..5af96c548 100644 --- a/deluge/ui/console/commands/add.py +++ b/deluge/ui/console/commands/add.py @@ -105,12 +105,13 @@ class Command(BaseCommand): # This path does not exist, so lets do a listdir on it's parent # and find any matches. ret = [] - for f in os.listdir(os.path.dirname(line)): - if f.startswith(os.path.split(line)[1]): - p = os.path.join(os.path.dirname(line), f) + if os.path.isdir(os.path.dirname(line)): + for f in os.listdir(os.path.dirname(line)): + if f.startswith(os.path.split(line)[1]): + p = os.path.join(os.path.dirname(line), f) - if os.path.isdir(p): - p += "/" - ret.append(p) + if os.path.isdir(p): + p += "/" + ret.append(p) return ret