forked from AkkomaGang/akkoma
Apply suggestion to lib/pleroma/web/emoji_api/emoji_api_controller.ex
This commit is contained in:
parent
f6d4acc871
commit
163082de6f
1 changed files with 6 additions and 14 deletions
|
@ -104,24 +104,16 @@ defp make_archive(name, pack, pack_dir) do
|
||||||
# Having a different pack.json md5 invalidates cache
|
# Having a different pack.json md5 invalidates cache
|
||||||
pack_file_md5 = :crypto.hash(:md5, File.read!(Path.join(pack_dir, "pack.json")))
|
pack_file_md5 = :crypto.hash(:md5, File.read!(Path.join(pack_dir, "pack.json")))
|
||||||
|
|
||||||
maybe_cached_pack = Cachex.get!(:emoji_packs_cache, name)
|
case Cachex.get!(:emoji_packs_cache, name) do
|
||||||
|
%{pack_file_md5: ^pack_file_md5, pack_data: zip_result} ->
|
||||||
zip_result =
|
|
||||||
if is_nil(maybe_cached_pack) do
|
|
||||||
create_archive_and_cache(name, pack, pack_dir, pack_file_md5)
|
|
||||||
else
|
|
||||||
if maybe_cached_pack[:pack_file_md5] == pack_file_md5 do
|
|
||||||
Logger.debug("Using cache for the '#{name}' shared emoji pack")
|
Logger.debug("Using cache for the '#{name}' shared emoji pack")
|
||||||
|
zip_result
|
||||||
|
|
||||||
maybe_cached_pack[:pack_data]
|
_ ->
|
||||||
else
|
|
||||||
create_archive_and_cache(name, pack, pack_dir, pack_file_md5)
|
create_archive_and_cache(name, pack, pack_dir, pack_file_md5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
zip_result
|
|
||||||
end
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
An endpoint for other instances (via admin UI) or users (via browser)
|
An endpoint for other instances (via admin UI) or users (via browser)
|
||||||
to download packs that the instance shares.
|
to download packs that the instance shares.
|
||||||
|
|
Loading…
Reference in a new issue