aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfshare.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/fshare.py b/fshare.py
index 6528602..228f5e6 100755
--- a/fshare.py
+++ b/fshare.py
@@ -179,7 +179,13 @@ class URLMap:
data = [l.strip().split() for l in self._file.readlines()]
self._short_to_full = dict(data)
self._full_to_short = dict(((b, a) for (a, b) in data))
- self._next_id = self._enc.decode_url(data[-1][0]) if len(data) else 0
+
+ try:
+ self._next_id = self._enc.decode_url(data[-1][0])
+ except (IndexError, ValueError):
+ # data is empty or the mapping uses characters not in alphabet
+ self._next_id = 0
+
except:
self.close()
raise