diff options
author | pacien | 2019-12-27 10:32:35 +0100 |
---|---|---|
committer | pacien | 2019-12-27 10:32:35 +0100 |
commit | 6bc29b5db2c8de62e2d9f21c25fa8dcd1ec5a75b (patch) | |
tree | fcc5bfee9ae1c14f9d2e3c7a6d38e82825d14d10 /compiler/src/Resource.hs | |
parent | 015d793b25a3f0d1ff275ed42ec211dd6a532ca0 (diff) | |
download | ldgallery-6bc29b5db2c8de62e2d9f21c25fa8dcd1ec5a75b.tar.gz |
compiler: extracting funcs
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r-- | compiler/src/Resource.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index 83f7438..a8be913 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs | |||
@@ -28,13 +28,13 @@ module Resource | |||
28 | , ItemProcessor | 28 | , ItemProcessor |
29 | , ThumbnailProcessor | 29 | , ThumbnailProcessor |
30 | , buildResourceTree | 30 | , buildResourceTree |
31 | , flattenResourceTree | 31 | , cleanupResourceDir |
32 | , outputDiff | ||
33 | ) where | 32 | ) where |
34 | 33 | ||
35 | 34 | ||
36 | import Data.Function ((&)) | 35 | import Data.Function ((&)) |
37 | import Data.List ((\\), subsequences) | 36 | import Data.List ((\\), subsequences, sortBy) |
37 | import Data.Ord (comparing) | ||
38 | import Data.Maybe (mapMaybe) | 38 | import Data.Maybe (mapMaybe) |
39 | import Files | 39 | import Files |
40 | import Input (InputTree(..), Sidecar) | 40 | import Input (InputTree(..), Sidecar) |
@@ -104,3 +104,11 @@ outputDiff resources ref = | |||
104 | 104 | ||
105 | fsPaths :: FSNode -> [Path] | 105 | fsPaths :: FSNode -> [Path] |
106 | fsPaths = map nodePath . tail . flattenDir | 106 | fsPaths = map nodePath . tail . flattenDir |
107 | |||
108 | cleanupResourceDir :: ResourceTree -> FileName -> IO () | ||
109 | cleanupResourceDir resourceTree outputDir = | ||
110 | readDirectory outputDir | ||
111 | >>= return . outputDiff resourceTree . root | ||
112 | >>= return . sortBy (flip $ comparing length) -- nested files before dirs | ||
113 | >>= return . map (localPath . (/>) outputDir) | ||
114 | >>= mapM_ remove | ||