diff --git a/src/library/entry.cr b/src/library/entry.cr index 92f4def..b5e582f 100644 --- a/src/library/entry.cr +++ b/src/library/entry.cr @@ -81,9 +81,17 @@ class Entry def cover_url return "#{Config.current.base_url}img/icon.png" if @err_msg + + unless @book.entry_cover_url_cache + TitleInfo.new @book.dir do |info| + @book.entry_cover_url_cache = info.entry_cover_url + end + end + entry_cover_url = @book.entry_cover_url_cache + url = "#{Config.current.base_url}api/cover/#{@book.id}/#{@id}" - TitleInfo.new @book.dir do |info| - info_url = info.entry_cover_url[@title]? + if entry_cover_url + info_url = entry_cover_url[@title]? unless info_url.nil? || info_url.empty? url = File.join Config.current.base_url, info_url end diff --git a/src/library/title.cr b/src/library/title.cr index 61c9813..6f2cf8c 100644 --- a/src/library/title.cr +++ b/src/library/title.cr @@ -3,9 +3,12 @@ require "../archive" class Title getter dir : String, parent_id : String, title_ids : Array(String), entries : Array(Entry), title : String, id : String, - encoded_title : String, mtime : Time, signature : UInt64 + encoded_title : String, mtime : Time, signature : UInt64, + entry_cover_url_cache : Hash(String, String)? + setter entry_cover_url_cache : Hash(String, String)? @entry_display_name_cache : Hash(String, String)? + @entry_cover_url_cache : Hash(String, String)? def initialize(@dir : String, @parent_id) storage = Storage.default