From 8a75458290002c765a0fa673912c162020de2bd1 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 30 Dec 2019 01:40:55 +0100 Subject: compiler: refactor path handling --- compiler/src/Processors.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'compiler/src/Processors.hs') diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index 7362822..ded3cc5 100644 --- a/compiler/src/Processors.hs +++ b/compiler/src/Processors.hs @@ -59,8 +59,8 @@ data Format = | Gif -- TODO: might be animated | Other -formatFromExt :: String -> Format -formatFromExt = aux . (map toLower) +formatFromPath :: Path -> Format +formatFromPath = aux . (map toLower) . fileName where aux ".bmp" = Bmp aux ".jpg" = Jpg @@ -169,10 +169,9 @@ type ItemFileProcessor = itemFileProcessor :: Maybe Resolution -> Cache -> ItemFileProcessor itemFileProcessor maxRes cached inputBase outputBase resClass inputRes = - cached (processor maxRes (extOf inputRes)) inPath outPath + cached (processor maxRes (formatFromPath inputRes)) inPath outPath >> return relOutPath where - extOf = formatFromExt . takeExtension . head relOutPath = resClass /> inputRes inPath = localPath $ inputBase /> inputRes outPath = localPath $ outputBase /> relOutPath @@ -196,10 +195,9 @@ type ThumbnailFileProcessor = thumbnailFileProcessor :: Resolution -> Cache -> ThumbnailFileProcessor thumbnailFileProcessor maxRes cached inputBase outputBase resClass inputRes = - cached <$> processor (extOf inputRes) + cached <$> processor (formatFromPath inputRes) & process where - extOf = formatFromExt . takeExtension . head relOutPath = resClass /> inputRes inPath = localPath $ inputBase /> inputRes outPath = localPath $ outputBase /> relOutPath -- cgit v1.2.3