From a62e3d979d542a320f3133b06c4318a762238082 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 20 Sep 2020 11:09:04 +0200 Subject: [PATCH] fxed a regression (geolocation cache) --- lib/location.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/location.py b/lib/location.py index 8388f72..72cb43c 100644 --- a/lib/location.py +++ b/lib/location.py @@ -105,7 +105,14 @@ def ipcache(ip_addr): if os.path.exists(cached): location = open(cached, 'r').read().split(';') - return location + if len(location) > 3: + return location[3], location[1] + elif len(location) > 1: + return location[0], location[1] + else: + return location[0], None + + return None, None def ip2location(ip_addr): "Convert IP address `ip_addr` to a location name" @@ -125,12 +132,11 @@ def ip2location(ip_addr): pass if location and ';' in location: + ipcachewrite(ip_addr, location) location = location.split(';')[3], location.split(';')[1] else: location = location, None - if location: - ipcachewrite(ip_addr, location) return location