Make a query before spawning cache actor task

This commit is contained in:
Thomas Sileo
2019-08-11 13:56:18 +02:00
parent 075d3c3742
commit 2a726b7dfb
3 changed files with 13 additions and 2 deletions

View File

@@ -136,8 +136,11 @@ class MediaCache(object):
remote_id=remote_id,
)
def is_actor_icon_cached(self, url: str) -> bool:
return bool(self.fs.find_one({"url": url, "kind": Kind.ACTOR_ICON.value}))
def cache_actor_icon(self, url: str) -> None:
if self.fs.find_one({"url": url, "kind": Kind.ACTOR_ICON.value}):
if self.is_actor_icon_cached(url):
return
i = load(url, self.user_agent)
for size in [50, 80]: