Fix incorrect extension used for ContentDB thumbnails
authorrubenwardy <rw@rubenwardy.com>
Sat, 6 Jun 2020 16:59:39 +0000 (17:59 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sat, 6 Jun 2020 17:31:39 +0000 (18:31 +0100)
builtin/mainmenu/dlg_contentstore.lua

index ae119f48ff1b8c95e7a37e3673f1dd6658d99373..b5c330f8f5655d895cd5105192864e0216571361 100644 (file)
@@ -133,6 +133,11 @@ local function start_install(calling_dialog, package)
        end
 end
 
+local function get_file_extension(path)
+       local parts = path:split(".")
+       return parts[#parts]
+end
+
 local function get_screenshot(package)
        if not package.thumbnail then
                return defaulttexturedir .. "no_screenshot.png"
@@ -141,8 +146,9 @@ local function get_screenshot(package)
        end
 
        -- Get tmp screenshot path
+       local ext = get_file_extension(package.thumbnail)
        local filepath = screenshot_dir .. DIR_DELIM ..
-               package.type .. "-" .. package.author .. "-" .. package.name .. ".png"
+               ("%s-%s-%s.%s"):format(package.type, package.author, package.name, ext)
 
        -- Return if already downloaded
        local file = io.open(filepath, "r")