This commit is contained in:
Loic Guegan 2020-10-09 14:35:08 +02:00
parent 404db42aea
commit d848b9ce3c

View file

@ -24,23 +24,23 @@ def notify_done(key):
data=dict()
with open(CACHE_FILE, 'rb') as f:
data=pickle.load(f)
if datetime.timestamp(datetime.now()) - data["ts"] >= CACHE_EXPIRE*60:
if datetime.timestamp(datetime.now()) - data[key] >= CACHE_EXPIRE*60:
remove(CACHE_FILE)
return(False)
else:
return(key in data["keys"])
return(key in data)
# Save notify key in cache
def add_key(key):
if not(path.exists(CACHE_FILE)):
with open(CACHE_FILE, 'wb') as f:
pickle.dump({"ts":datetime.timestamp(datetime.now()),"keys":key},f)
pickle.dump({key:datetime.timestamp(datetime.now())},f)
else:
data=list()
with open(CACHE_FILE, 'rb') as f:
data=pickle.load(f)
if not(key in data["keys"]):
data["keys"].append(key)
data[key]=datetime.timestamp(datetime.now())
with open(CACHE_FILE, 'wb') as f:
pickle.dump(data,f)