From 005ea7957a75e53b443bbc5a596909df457343b8 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 26 Oct 2020 12:43:49 +0100 Subject: compiler/Caching: fix cache thumbnail masking in index GitHub: closes #280 --- compiler/src/Caching.hs | 6 +++--- compiler/src/Compiler.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler') diff --git a/compiler/src/Caching.hs b/compiler/src/Caching.hs index c2b5a43..1a8b710 100644 --- a/compiler/src/Caching.hs +++ b/compiler/src/Caching.hs @@ -53,7 +53,7 @@ buildItemCache cachedItems = lookupCache cachedMap = Map.fromList (map withKey cachedItemList) lookupCache path = Map.lookup (webPath path) cachedMap -useCached :: ItemCache -> (GalleryItem -> a) -> Cache a +useCached :: ItemCache -> (GalleryItem -> Maybe a) -> Cache a useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = do isDir <- doesDirectoryExist outputFsPath @@ -63,7 +63,7 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = if fileExists then do needUpdate <- isOutdated True inputFsPath outputFsPath - case (needUpdate, cache itemPath) of + case (needUpdate, cache itemPath >>= propGetter) of (False, Just props) -> fromCache props _ -> update else @@ -73,4 +73,4 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = update = processor itemPath resPath inputFsPath outputFsPath fromCache props = putStrLn ("From cache:\t" ++ outputFsPath) - >> return (propGetter props) + >> return props diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index 1ec55c5..4111f02 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs @@ -147,8 +147,8 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir cachedIndex <- loadCachedIndex galleryIndexPath let cache = mkCache cachedIndex - let itemProc = itemProcessor config (cache Resource.properties) - let thumbnailProc = thumbnailProcessor config (cache Resource.thumbnail) + let itemProc = itemProcessor config (cache $ return . Resource.properties) + let thumbnailProc = thumbnailProcessor config (cache $ fmap return . Resource.thumbnail) let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) resources <- galleryBuilder curatedInputTree @@ -170,7 +170,7 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir then return Nothing else loadGalleryIndex galleryIndexPath - mkCache :: Maybe GalleryIndex -> (GalleryItem -> a) -> Cache a + mkCache :: Maybe GalleryIndex -> (GalleryItem -> Maybe a) -> Cache a mkCache refGalleryIndex = if rebuildAll then const noCache -- cgit v1.2.3