From 2ebdb15398bcd19d650afd0ff4b034ab0aae1706 Mon Sep 17 00:00:00 2001 From: Gregory Danielson Date: Sun, 1 Nov 2020 16:37:26 -0600 Subject: [PATCH] Adjust ipcachewrite to account for region addition --- lib/location.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/location.py b/lib/location.py index 2dd190b..337772e 100644 --- a/lib/location.py +++ b/lib/location.py @@ -90,10 +90,15 @@ def geolocator(location): def ipcachewrite(ip_addr, location): - cached = os.path.join(IP2LCACHE, ip_addr) + """ Write a retrieved ip+location into cache + Can stress some filesystems after long term use, see + https://stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory + """ + cachefile = os.path.join(IP2LCACHE, ip_addr) if not os.path.exists(IP2LCACHE): os.makedirs(IP2LCACHE) - with open(cached, 'w') as file: + + with open(cachefile, 'w') as file: file.write(location[0] + ';' + location[1] + ';' + location[2]) # like ip2location format, but reversed