diff options
author | pacien | 2020-02-03 15:08:46 +0100 |
---|---|---|
committer | pacien | 2020-02-03 21:19:56 +0100 |
commit | b757ee814c01c83b17b495c4805fcc70d7e08c89 (patch) | |
tree | e9d13d94e400205d8eaa8a5bd3b74f191ac1f204 | |
parent | 1d7299bced057e3c0e6cc76507fc25d6f493968e (diff) | |
download | ldgallery-b757ee814c01c83b17b495c4805fcc70d7e08c89.tar.gz |
compiler: simplify checks
-rw-r--r-- | compiler/src/Compiler.hs | 8 | ||||
-rw-r--r-- | compiler/src/Processors.hs | 4 |
2 files changed, 4 insertions, 8 deletions
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index adc4a5f..2a0dccc 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs | |||
@@ -22,7 +22,7 @@ module Compiler | |||
22 | ) where | 22 | ) where |
23 | 23 | ||
24 | 24 | ||
25 | import Control.Monad (liftM2) | 25 | import Control.Monad (liftM2, when) |
26 | import Data.List (any) | 26 | import Data.List (any) |
27 | import System.FilePath ((</>)) | 27 | import System.FilePath ((</>)) |
28 | import qualified System.FilePath.Glob as Glob | 28 | import qualified System.FilePath.Glob as Glob |
@@ -118,11 +118,7 @@ compileGallery inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = | |||
118 | let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) | 118 | let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) |
119 | resources <- galleryBuilder (galleryName config) inputTree | 119 | resources <- galleryBuilder (galleryName config) inputTree |
120 | 120 | ||
121 | if cleanOutput then | 121 | when cleanOutput $ galleryCleanupResourceDir resources outputDirPath |
122 | galleryCleanupResourceDir resources outputDirPath | ||
123 | else | ||
124 | return () | ||
125 | |||
126 | writeJSON outputIndex resources | 122 | writeJSON outputIndex resources |
127 | writeJSON outputViewerConf $ viewer fullConfig | 123 | writeJSON outputViewerConf $ viewer fullConfig |
128 | 124 | ||
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index 6ab4eb5..faa2f43 100644 --- a/compiler/src/Processors.hs +++ b/compiler/src/Processors.hs | |||
@@ -25,6 +25,7 @@ module Processors | |||
25 | 25 | ||
26 | 26 | ||
27 | import Control.Exception (Exception, throwIO) | 27 | import Control.Exception (Exception, throwIO) |
28 | import Control.Monad (when) | ||
28 | import Data.Function ((&)) | 29 | import Data.Function ((&)) |
29 | import Data.Char (toLower) | 30 | import Data.Char (toLower) |
30 | import Data.List (break) | 31 | import Data.List (break) |
@@ -106,7 +107,7 @@ withCached :: Cache | |||
106 | withCached processor inputPath outputPath = | 107 | withCached processor inputPath outputPath = |
107 | do | 108 | do |
108 | isDir <- doesDirectoryExist outputPath | 109 | isDir <- doesDirectoryExist outputPath |
109 | if isDir then removePathForcibly outputPath else noop | 110 | when isDir $ removePathForcibly outputPath |
110 | 111 | ||
111 | fileExists <- doesFileExist outputPath | 112 | fileExists <- doesFileExist outputPath |
112 | if fileExists then | 113 | if fileExists then |
@@ -117,7 +118,6 @@ withCached processor inputPath outputPath = | |||
117 | update | 118 | update |
118 | 119 | ||
119 | where | 120 | where |
120 | noop = return () | ||
121 | update = processor inputPath outputPath | 121 | update = processor inputPath outputPath |
122 | skip = putStrLn $ "Skipping:\t" ++ outputPath | 122 | skip = putStrLn $ "Skipping:\t" ++ outputPath |
123 | 123 | ||