aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Input.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Input.hs')
-rw-r--r--compiler/src/Input.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 95d8132..cb837e3 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -30,11 +30,12 @@ import Data.Function ((&))
30import Data.Maybe (catMaybes) 30import Data.Maybe (catMaybes)
31import Data.Bool (bool) 31import Data.Bool (bool)
32import Data.List (find) 32import Data.List (find)
33import Data.Time.Clock (UTCTime)
33import Data.Time.LocalTime (ZonedTime) 34import Data.Time.LocalTime (ZonedTime)
34import Data.Yaml (ParseException, decodeFileEither) 35import Data.Yaml (ParseException, decodeFileEither)
35import Data.Aeson (FromJSON) 36import Data.Aeson (FromJSON)
36import System.FilePath (isExtensionOf, dropExtension) 37import System.FilePath (isExtensionOf, dropExtension)
37import System.Directory (doesFileExist) 38import System.Directory (doesFileExist, getModificationTime)
38 39
39import Files 40import Files
40 41
@@ -52,9 +53,11 @@ decodeYamlFile path =
52data InputTree = 53data InputTree =
53 InputFile 54 InputFile
54 { path :: Path 55 { path :: Path
56 , modTime :: UTCTime
55 , sidecar :: Sidecar } 57 , sidecar :: Sidecar }
56 | InputDir 58 | InputDir
57 { path :: Path 59 { path :: Path
60 , modTime :: UTCTime
58 , dirThumbnailPath :: Maybe Path 61 , dirThumbnailPath :: Maybe Path
59 , items :: [InputTree] } 62 , items :: [InputTree] }
60 deriving Show 63 deriving Show
@@ -91,18 +94,20 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
91 mkInputNode :: FSNode -> IO (Maybe InputTree) 94 mkInputNode :: FSNode -> IO (Maybe InputTree)
92 mkInputNode file@File{path} 95 mkInputNode file@File{path}
93 | (not $ isSidecar file) && (not $ isThumbnail file) = 96 | (not $ isSidecar file) && (not $ isThumbnail file) =
94 readSidecarFile (localPath $ anchor /> path <.> sidecarExt) 97 do
95 >>= return . InputFile path 98 sidecar <- readSidecarFile $ localPath (anchor /> path <.> sidecarExt)
96 >>= return . Just 99 modTime <- getModificationTime $ localPath (anchor /> path)
100 return $ Just $ InputFile path modTime sidecar
97 mkInputNode File{} = return Nothing 101 mkInputNode File{} = return Nothing
98 mkInputNode dir@Dir{} = mkDirNode dir >>= return . Just 102 mkInputNode dir@Dir{} = mkDirNode dir >>= return . Just
99 103
100 mkDirNode :: FSNode -> IO InputTree 104 mkDirNode :: FSNode -> IO InputTree
101 mkDirNode File{} = throw $ AssertionFailed "Input directory is a file" 105 mkDirNode File{} = throw $ AssertionFailed "Input directory is a file"
102 mkDirNode Dir{path, items} = 106 mkDirNode Dir{path, items} =
103 mapM mkInputNode items 107 do
104 >>= return . catMaybes 108 dirItems <- mapM mkInputNode items
105 >>= return . InputDir path (findThumbnail items) 109 modTime <- getModificationTime $ localPath (anchor /> path)
110 return $ InputDir path modTime (findThumbnail items) (catMaybes dirItems)
106 111
107 isSidecar :: FSNode -> Bool 112 isSidecar :: FSNode -> Bool
108 isSidecar Dir{} = False 113 isSidecar Dir{} = False