diff options
author | pacien | 2020-01-05 16:24:02 +0100 |
---|---|---|
committer | pacien | 2020-01-05 16:24:02 +0100 |
commit | 9dd271504160b624284dbc438cdc867b6ca0d0e7 (patch) | |
tree | 8701aa1897e664aab1f80a7952dbdc5c0c27624c /compiler/src/Processors.hs | |
parent | abdf82bbfde843a87bd00746f52dafdd28f3f60b (diff) | |
download | ldgallery-9dd271504160b624284dbc438cdc867b6ca0d0e7.tar.gz |
compiler: enable warnings and fix them
GitHub: fixes #9
Diffstat (limited to 'compiler/src/Processors.hs')
-rw-r--r-- | compiler/src/Processors.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index 2525af4..6ee8c78 100644 --- a/compiler/src/Processors.hs +++ b/compiler/src/Processors.hs | |||
@@ -32,7 +32,7 @@ module Processors | |||
32 | ) where | 32 | ) where |
33 | 33 | ||
34 | 34 | ||
35 | import Control.Exception (Exception, throwIO) | 35 | import Control.Exception (Exception, PatternMatchFail(..), throw, throwIO) |
36 | import Data.Function ((&)) | 36 | import Data.Function ((&)) |
37 | import Data.Ratio ((%)) | 37 | import Data.Ratio ((%)) |
38 | import Data.Char (toLower) | 38 | import Data.Char (toLower) |
@@ -90,12 +90,13 @@ resizeStaticImageUpTo Jpg = resizeStaticGeneric readJpeg (saveJpgImage 80) | |||
90 | resizeStaticImageUpTo Png = resizeStaticGeneric readPng savePngImage | 90 | resizeStaticImageUpTo Png = resizeStaticGeneric readPng savePngImage |
91 | resizeStaticImageUpTo Tiff = resizeStaticGeneric readTiff saveTiffImage | 91 | resizeStaticImageUpTo Tiff = resizeStaticGeneric readTiff saveTiffImage |
92 | resizeStaticImageUpTo Hdr = resizeStaticGeneric readHDR saveRadianceImage | 92 | resizeStaticImageUpTo Hdr = resizeStaticGeneric readHDR saveRadianceImage |
93 | resizeStaticImageUpTo Gif = resizeStaticGeneric readGif writeGifImage | 93 | resizeStaticImageUpTo Gif = resizeStaticGeneric readGif saveGifImage' |
94 | where | 94 | where |
95 | writeGifImage :: StaticImageWriter | 95 | saveGifImage' :: StaticImageWriter |
96 | writeGifImage outputPath image = | 96 | saveGifImage' outputPath image = |
97 | saveGifImage outputPath image | 97 | saveGifImage outputPath image |
98 | & either (throwIO . ProcessingException outputPath) id | 98 | & either (throwIO . ProcessingException outputPath) id |
99 | resizeStaticImageUpTo _ = throw $ PatternMatchFail "Unhandled format" | ||
99 | 100 | ||
100 | 101 | ||
101 | type StaticImageReader = FilePath -> IO (Either String DynamicImage) | 102 | type StaticImageReader = FilePath -> IO (Either String DynamicImage) |
@@ -166,14 +167,14 @@ type ItemFileProcessor = | |||
166 | -> ItemProcessor | 167 | -> ItemProcessor |
167 | 168 | ||
168 | itemFileProcessor :: Maybe Resolution -> Cache -> ItemFileProcessor | 169 | itemFileProcessor :: Maybe Resolution -> Cache -> ItemFileProcessor |
169 | itemFileProcessor maxRes cached inputBase outputBase resClass inputRes = | 170 | itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes = |
170 | cached processor inPath outPath | 171 | cached processor inPath outPath |
171 | >> return (relOutPath, props) | 172 | >> return (relOutPath, props) |
172 | where | 173 | where |
173 | relOutPath = resClass /> inputRes | 174 | relOutPath = resClass /> inputRes |
174 | inPath = localPath $ inputBase /> inputRes | 175 | inPath = localPath $ inputBase /> inputRes |
175 | outPath = localPath $ outputBase /> relOutPath | 176 | outPath = localPath $ outputBase /> relOutPath |
176 | (processor, props) = formatProcessor maxRes $ formatFromPath inputRes | 177 | (processor, props) = formatProcessor maxResolution $ formatFromPath inputRes |
177 | 178 | ||
178 | formatProcessor :: Maybe Resolution -> Format -> (FileProcessor, GalleryItemProps) | 179 | formatProcessor :: Maybe Resolution -> Format -> (FileProcessor, GalleryItemProps) |
179 | formatProcessor Nothing _ = (copyFileProcessor, Other) | 180 | formatProcessor Nothing _ = (copyFileProcessor, Other) |
@@ -203,8 +204,8 @@ thumbnailFileProcessor maxRes cached inputBase outputBase resClass inputRes = | |||
203 | 204 | ||
204 | process :: Maybe FileProcessor -> IO (Maybe Path) | 205 | process :: Maybe FileProcessor -> IO (Maybe Path) |
205 | process Nothing = return Nothing | 206 | process Nothing = return Nothing |
206 | process (Just processor) = | 207 | process (Just proc) = |
207 | processor inPath outPath | 208 | proc inPath outPath |
208 | >> return (Just relOutPath) | 209 | >> return (Just relOutPath) |
209 | 210 | ||
210 | processor :: Format -> Maybe FileProcessor | 211 | processor :: Format -> Maybe FileProcessor |