diff options
author | pacien | 2020-02-14 15:39:56 +0100 |
---|---|---|
committer | Notkea | 2020-02-17 21:07:39 +0100 |
commit | 395a76bc4193c0c7182f87778458a68d0079e836 (patch) | |
tree | 72a4e6fd10ff8053f5a3e7fdbf4f6d63817ac00b /compiler/src/Input.hs | |
parent | c3c69b601d834c8df7cba88a0d3149b56cdd5d14 (diff) | |
download | ldgallery-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.hs | 7 |
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 | |||
79 | sidecarExt :: String | 80 | sidecarExt :: String |
80 | sidecarExt = "yaml" | 81 | sidecarExt = "yaml" |
81 | 82 | ||
83 | dirSidecar :: String | ||
84 | dirSidecar = "directory." ++ sidecarExt | ||
85 | |||
82 | readSidecarFile :: FilePath -> IO Sidecar | 86 | readSidecarFile :: FilePath -> IO Sidecar |
83 | readSidecarFile filepath = | 87 | readSidecarFile 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 |