diff options
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r-- | compiler/src/Resource.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index c08677d..607c7f6 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs | |||
@@ -29,6 +29,7 @@ import Data.List.Ordered (minusBy) | |||
29 | import Data.Char (toLower) | 29 | import Data.Char (toLower) |
30 | import Data.Maybe (mapMaybe, fromMaybe) | 30 | import Data.Maybe (mapMaybe, fromMaybe) |
31 | import Data.Function ((&)) | 31 | import Data.Function ((&)) |
32 | import Data.Functor ((<&>)) | ||
32 | import qualified Data.Set as Set | 33 | import qualified Data.Set as Set |
33 | import Data.Text (pack) | 34 | import Data.Text (pack) |
34 | import Data.Time.Clock (UTCTime) | 35 | import Data.Time.Clock (UTCTime) |
@@ -119,8 +120,8 @@ type ThumbnailProcessor = Path -> IO (Maybe Thumbnail) | |||
119 | buildGalleryTree :: | 120 | buildGalleryTree :: |
120 | ItemProcessor -> ThumbnailProcessor -> TagsFromDirectoriesConfig | 121 | ItemProcessor -> ThumbnailProcessor -> TagsFromDirectoriesConfig |
121 | -> InputTree -> IO GalleryItem | 122 | -> InputTree -> IO GalleryItem |
122 | buildGalleryTree processItem processThumbnail tagsFromDirsConfig inputTree = | 123 | buildGalleryTree processItem processThumbnail tagsFromDirsConfig = |
123 | mkGalleryItem [] inputTree | 124 | mkGalleryItem [] |
124 | where | 125 | where |
125 | mkGalleryItem :: [Tag] -> InputTree -> IO GalleryItem | 126 | mkGalleryItem :: [Tag] -> InputTree -> IO GalleryItem |
126 | mkGalleryItem inheritedTags InputFile{path, modTime, sidecar} = | 127 | mkGalleryItem inheritedTags InputFile{path, modTime, sidecar} = |
@@ -190,7 +191,7 @@ flattenGalleryTree simple = [simple] | |||
190 | 191 | ||
191 | galleryOutputDiff :: GalleryItem -> FSNode -> [Path] | 192 | galleryOutputDiff :: GalleryItem -> FSNode -> [Path] |
192 | galleryOutputDiff resources ref = | 193 | galleryOutputDiff resources ref = |
193 | (filesystemPaths ref) \\ (compiledPaths $ flattenGalleryTree resources) | 194 | filesystemPaths ref \\ compiledPaths (flattenGalleryTree resources) |
194 | where | 195 | where |
195 | filesystemPaths :: FSNode -> [Path] | 196 | filesystemPaths :: FSNode -> [Path] |
196 | filesystemPaths = map Files.path . tail . flattenDir | 197 | filesystemPaths = map Files.path . tail . flattenDir |
@@ -212,8 +213,7 @@ galleryOutputDiff resources ref = | |||
212 | 213 | ||
213 | thumbnailPaths :: [GalleryItem] -> [Path] | 214 | thumbnailPaths :: [GalleryItem] -> [Path] |
214 | thumbnailPaths = | 215 | thumbnailPaths = |
215 | map resourcePath | 216 | map (resourcePath . (resource :: (Thumbnail -> Resource))) |
216 | . map (resource :: (Thumbnail -> Resource)) | ||
217 | . mapMaybe thumbnail | 217 | . mapMaybe thumbnail |
218 | 218 | ||
219 | (\\) :: [Path] -> [Path] -> [Path] | 219 | (\\) :: [Path] -> [Path] -> [Path] |
@@ -235,7 +235,7 @@ galleryOutputDiff resources ref = | |||
235 | galleryCleanupResourceDir :: GalleryItem -> FileName -> IO () | 235 | galleryCleanupResourceDir :: GalleryItem -> FileName -> IO () |
236 | galleryCleanupResourceDir resourceTree outputDir = | 236 | galleryCleanupResourceDir resourceTree outputDir = |
237 | readDirectory outputDir | 237 | readDirectory outputDir |
238 | >>= return . galleryOutputDiff resourceTree . root | 238 | <&> galleryOutputDiff resourceTree . root |
239 | >>= return . sortOn ((0 -) . pathLength) -- nested files before their parent dirs | 239 | <&> sortOn ((0 -) . pathLength) -- nested files before their parent dirs |
240 | >>= return . map (localPath . (/>) outputDir) | 240 | <&> map (localPath . (/>) outputDir) |
241 | >>= mapM_ remove | 241 | >>= mapM_ remove |