aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Input.hs
diff options
context:
space:
mode:
authorpacien2020-02-14 15:39:56 +0100
committerNotkea2020-02-17 21:07:39 +0100
commit395a76bc4193c0c7182f87778458a68d0079e836 (patch)
tree72a4e6fd10ff8053f5a3e7fdbf4f6d63817ac00b /compiler/src/Input.hs
parentc3c69b601d834c8df7cba88a0d3149b56cdd5d14 (diff)
downloadldgallery-395a76bc4193c0c7182f87778458a68d0079e836.tar.gz
compiler: metadata sidecar for whole directories
GitHub: closes #3
Diffstat (limited to 'compiler/src/Input.hs')
-rw-r--r--compiler/src/Input.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index cb837e3..e0fc8ef 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -58,6 +58,7 @@ data InputTree =
58 | InputDir 58 | InputDir
59 { path :: Path 59 { path :: Path
60 , modTime :: UTCTime 60 , modTime :: UTCTime
61 , sidecar :: Sidecar
61 , dirThumbnailPath :: Maybe Path 62 , dirThumbnailPath :: Maybe Path
62 , items :: [InputTree] } 63 , items :: [InputTree] }
63 deriving Show 64 deriving Show
@@ -79,6 +80,9 @@ emptySidecar = Sidecar
79sidecarExt :: String 80sidecarExt :: String
80sidecarExt = "yaml" 81sidecarExt = "yaml"
81 82
83dirSidecar :: String
84dirSidecar = "directory." ++ sidecarExt
85
82readSidecarFile :: FilePath -> IO Sidecar 86readSidecarFile :: FilePath -> IO Sidecar
83readSidecarFile filepath = 87readSidecarFile filepath =
84 doesFileExist filepath 88 doesFileExist filepath
@@ -107,7 +111,8 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
107 do 111 do
108 dirItems <- mapM mkInputNode items 112 dirItems <- mapM mkInputNode items
109 modTime <- getModificationTime $ localPath (anchor /> path) 113 modTime <- getModificationTime $ localPath (anchor /> path)
110 return $ InputDir path modTime (findThumbnail items) (catMaybes dirItems) 114 sidecar <- readSidecarFile $ localPath (anchor /> path </ dirSidecar)
115 return $ InputDir path modTime sidecar (findThumbnail items) (catMaybes dirItems)
111 116
112 isSidecar :: FSNode -> Bool 117 isSidecar :: FSNode -> Bool
113 isSidecar Dir{} = False 118 isSidecar Dir{} = False