1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Removing proxied image after they expire

This commit is contained in:
krateng 2023-04-01 16:11:20 +02:00
parent 31aaf23d80
commit 72826f87fe

View File

@ -21,7 +21,7 @@ import sqlalchemy as sql
MAX_RESOLVE_THREADS = 10 MAX_RESOLVE_THREADS = 5
# remove old db file (columns missing) # remove old db file (columns missing)
@ -126,10 +126,19 @@ def remove_image_from_cache(track_id=None,artist_id=None,album_id=None):
with engine.begin() as conn: with engine.begin() as conn:
op = DB[table].delete().where( op = DB[table].delete().where(
DB[table].c.id==entity_id, DB[table].c.id==entity_id,
).returning(
DB[table].c.id,
DB[table].c.localproxyurl
) )
result = conn.execute(op) result = conn.execute(op).all()
for row in result:
targetpath = data_dir['cache']('images',row.localproxyurl.split('/')[-1])
try:
os.remove(targetpath)
except:
pass
# TODO delete proxy
def dl_image(url): def dl_image(url):
try: try: