aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/Caching.hs6
-rw-r--r--compiler/src/Compiler.hs6
2 files changed, 6 insertions, 6 deletions
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
53 cachedMap = Map.fromList (map withKey cachedItemList) 53 cachedMap = Map.fromList (map withKey cachedItemList)
54 lookupCache path = Map.lookup (webPath path) cachedMap 54 lookupCache path = Map.lookup (webPath path) cachedMap
55 55
56useCached :: ItemCache -> (GalleryItem -> a) -> Cache a 56useCached :: ItemCache -> (GalleryItem -> Maybe a) -> Cache a
57useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = 57useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
58 do 58 do
59 isDir <- doesDirectoryExist outputFsPath 59 isDir <- doesDirectoryExist outputFsPath
@@ -63,7 +63,7 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
63 if fileExists then 63 if fileExists then
64 do 64 do
65 needUpdate <- isOutdated True inputFsPath outputFsPath 65 needUpdate <- isOutdated True inputFsPath outputFsPath
66 case (needUpdate, cache itemPath) of 66 case (needUpdate, cache itemPath >>= propGetter) of
67 (False, Just props) -> fromCache props 67 (False, Just props) -> fromCache props
68 _ -> update 68 _ -> update
69 else 69 else
@@ -73,4 +73,4 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
73 update = processor itemPath resPath inputFsPath outputFsPath 73 update = processor itemPath resPath inputFsPath outputFsPath
74 fromCache props = 74 fromCache props =
75 putStrLn ("From cache:\t" ++ outputFsPath) 75 putStrLn ("From cache:\t" ++ outputFsPath)
76 >> return (propGetter props) 76 >> 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
147 cachedIndex <- loadCachedIndex galleryIndexPath 147 cachedIndex <- loadCachedIndex galleryIndexPath
148 let cache = mkCache cachedIndex 148 let cache = mkCache cachedIndex
149 149
150 let itemProc = itemProcessor config (cache Resource.properties) 150 let itemProc = itemProcessor config (cache $ return . Resource.properties)
151 let thumbnailProc = thumbnailProcessor config (cache Resource.thumbnail) 151 let thumbnailProc = thumbnailProcessor config (cache $ fmap return . Resource.thumbnail)
152 let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) 152 let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config)
153 resources <- galleryBuilder curatedInputTree 153 resources <- galleryBuilder curatedInputTree
154 154
@@ -170,7 +170,7 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir
170 then return Nothing 170 then return Nothing
171 else loadGalleryIndex galleryIndexPath 171 else loadGalleryIndex galleryIndexPath
172 172
173 mkCache :: Maybe GalleryIndex -> (GalleryItem -> a) -> Cache a 173 mkCache :: Maybe GalleryIndex -> (GalleryItem -> Maybe a) -> Cache a
174 mkCache refGalleryIndex = 174 mkCache refGalleryIndex =
175 if rebuildAll 175 if rebuildAll
176 then const noCache 176 then const noCache