From aaf9d20c644ccf3bbc2755ebf3a9fb46f8c78b86 Mon Sep 17 00:00:00 2001 From: WS64 Date: Sat, 23 Aug 2014 11:21:37 +0200 Subject: [PATCH] Give cover images unique names and keep them 30 days --- frontend/ui/uitoolbox.lua | 79 +++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/frontend/ui/uitoolbox.lua b/frontend/ui/uitoolbox.lua index 11fb0320c..0d8b06db3 100644 --- a/frontend/ui/uitoolbox.lua +++ b/frontend/ui/uitoolbox.lua @@ -12,7 +12,7 @@ function UIToolbox:getPicture(file) local function check_extension(cover) if cover then local itype = string.lower(string.match(cover, ".+%.([^.]+)") or "") - if not (itype == "png" or itype == "jpg" or itype == "jpeg" or itype == "tiff") then + if not (itype == "png" or itype == "jpg" or itype == "jpeg") then cover = nil end end @@ -70,40 +70,63 @@ function UIToolbox:getPicture(file) return check_extension(cover) end + local function checkoldfile(cover) + if io.open(cover) then + return cover + end + end + local cover - if file then - pcall(lfs.mkdir("temp")) - pcall(os.execute("rm -rf " .. epub_folder)) - pcall(lfs.mkdir(epub_folder)) - pcall(os.execute("unzip \"" .. file .. "\" cover.jpeg -oq -d " .. epub_folder)) - if io.open(epub_folder .. "/cover.jpeg","r") then -- picture in main folder - cover = epub_folder .. "/cover.jpeg" -- found one - else - pcall(os.execute("unzip \"" .. file .. "\" \"META-INF/container.xml\" -oq -d " .. epub_folder)) -- read container.xml - contentopf = getValue(epub_folder .. "/META-INF/container.xml","^%s*