Tweak gridfs cleanup task

This commit is contained in:
Thomas Sileo 2019-04-08 16:55:46 +02:00
parent 12faea3c29
commit 849a6c4ea0

10
app.py
View file

@ -1422,7 +1422,10 @@ def admin_cleanup2():
): ):
# Delete the cached attachment/ # Delete the cached attachment/
for grid_item in MEDIA_CACHE.fs.find({"remote_id": data["remote_id"]}): for grid_item in MEDIA_CACHE.fs.find({"remote_id": data["remote_id"]}):
MEDIA_CACHE.fs.delete(grid_item._id) try:
MEDIA_CACHE.fs.delete(grid_item._id)
except Exception:
pass
# Delete the Create activities that no longer have cached attachments # Delete the Create activities that no longer have cached attachments
DB.activities.delete_many( DB.activities.delete_many(
@ -1451,7 +1454,10 @@ def admin_cleanup3():
for grid_item in MEDIA_CACHE.fs.find( for grid_item in MEDIA_CACHE.fs.find(
{"kind": {"$in": ["og", "attachment"]}, "remote_id": {"$exists": False}} {"kind": {"$in": ["og", "attachment"]}, "remote_id": {"$exists": False}}
): ):
MEDIA_CACHE.fs.delete(grid_item._id) try:
MEDIA_CACHE.fs.delete(grid_item._id)
except Exception:
pass
# TODO(tsileo): iterator over "actor_icon" and look for unused one in a separate task # TODO(tsileo): iterator over "actor_icon" and look for unused one in a separate task