aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-05 17:59:33 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-06-05 17:59:33 +0200
commitef93be6c2c8685176de5681bc7ebd349cd21d789 (patch)
treeb6f066216d444ac43c8a224d115560b8fe7377cd /src
parent5e68d300aad04406adcc974a64e7436b7b2f8cea (diff)
add `listAllFiles`
Diffstat (limited to 'src')
-rw-r--r--src/Store/Store.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Store/Store.hs b/src/Store/Store.hs
index b58a2da..e0bbdfb 100644
--- a/src/Store/Store.hs
+++ b/src/Store/Store.hs
@@ -3,6 +3,7 @@ module Store.Store
withStore,
withCommit,
listFiles,
+ listAllFiles,
readFile,
writeFile,
deleteFile,
@@ -116,6 +117,25 @@ listFiles :: FilePath -> StoreM [FilePath]
listFiles =
fmap (filter (not . (isSuffixOf "/"))) . listDirectory
+listAllFiles :: StoreM [FilePath]
+listAllFiles = do
+ State {tid} <- get
+ Env {repo} <- ask
+ lift $ G.runRepository GB.lgFactory repo $ do
+ tree <- G.lookupTree tid
+ filter (not . isSuffixOf "/")
+ . sort
+ . map fst
+ . map
+ ( \e ->
+ case snd e of
+ G.BlobEntry _ _ -> e
+ G.CommitEntry _ -> error "XXX commit entry"
+ G.TreeEntry _ -> first addTrailingPathSeparator e
+ )
+ . map (first (("/" <>) . B.toString))
+ <$> G.listTreeEntries tree
+
data DoesNotExist = DoesNotExist String FilePath
deriving (Show)