diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-06-05 17:59:33 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-06-05 17:59:33 +0200 |
commit | ef93be6c2c8685176de5681bc7ebd349cd21d789 (patch) | |
tree | b6f066216d444ac43c8a224d115560b8fe7377cd /src/Store | |
parent | 5e68d300aad04406adcc974a64e7436b7b2f8cea (diff) |
add `listAllFiles`
Diffstat (limited to 'src/Store')
-rw-r--r-- | src/Store/Store.hs | 20 |
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) |