Skip to content
Snippets Groups Projects
Commit df25e24f authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

start building a directory hierarchy instead of a flat result

parent 0d0f8f19
No related branches found
No related tags found
1 merge request!2Implement basic read-only support for magic-folders
......@@ -82,7 +82,7 @@ type Grid = Map.Map StorageServerID StorageServerAnnouncement
data FolderEntry
= Directory
{ directoryChildren :: Map.Map DecodedPath FolderEntry
{ directoryChildren :: Map.Map T.Text FolderEntry
}
| File
{ fileContent :: CHK.Reader
......@@ -138,7 +138,11 @@ getFolderFiles grid MagicFolder{folderCollectiveReadCap, ourPersonalWriteCap} =
-- XXX Lose the parse errors here. They don't fit into a simple
-- Directory representation. Do something about this so errors
-- are visible.
pure . Right . Directory $ Map.fromList parsedEntries
pure . Right . foldr addToHierarchy Directory{directoryChildren = mempty} $ parsedEntries
addToHierarchy :: (DecodedPath, FolderEntry) -> FolderEntry -> FolderEntry
addToHierarchy (DecodedPath [basename], entry) d@Directory{directoryChildren} =
d{directoryChildren = Map.insert basename entry directoryChildren}
snapshotToEntry :: Snapshot -> Maybe FolderEntry
snapshotToEntry Snapshot{snapshotContentCap, snapshotMetadataCap} = Just $ File snapshotContentCap snapshotMetadataCap
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment