aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Resource.hs
diff options
context:
space:
mode:
authorpacien2019-12-27 10:32:35 +0100
committerpacien2019-12-27 10:32:35 +0100
commit6bc29b5db2c8de62e2d9f21c25fa8dcd1ec5a75b (patch)
treefcc5bfee9ae1c14f9d2e3c7a6d38e82825d14d10 /compiler/src/Resource.hs
parent015d793b25a3f0d1ff275ed42ec211dd6a532ca0 (diff)
downloadldgallery-6bc29b5db2c8de62e2d9f21c25fa8dcd1ec5a75b.tar.gz
compiler: extracting funcs
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r--compiler/src/Resource.hs14
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
36import Data.Function ((&)) 35import Data.Function ((&))
37import Data.List ((\\), subsequences) 36import Data.List ((\\), subsequences, sortBy)
37import Data.Ord (comparing)
38import Data.Maybe (mapMaybe) 38import Data.Maybe (mapMaybe)
39import Files 39import Files
40import Input (InputTree(..), Sidecar) 40import 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
108cleanupResourceDir :: ResourceTree -> FileName -> IO ()
109cleanupResourceDir 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