lsd-transfer/listener.py

12 lines
327 B
Python
Raw Permalink Normal View History

2019-07-30 13:08:45 +02:00
import redis, os
UPLOAD_DIR = '/storage/'
r = redis.StrictRedis()
pubsub = r.pubsub()
pubsub.psubscribe("*")
for msg in pubsub.listen():
if msg['channel'].decode('utf-8') == '__keyevent@0__:expired':
os.remove(UPLOAD_DIR + msg['data'].decode('utf-8'))
print("Deleted file " + msg['data'].decode('utf-8'))