Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394module Sources.Services.Ipfs.Marker exposing (concat, removeOne, separator, takeOne)
{-| Marker stuff for IPFS.
The IPFS API currently doesn't have a way to return a tree.So we have build one ourselves.
How it works:
1. We list the objects in a given directory2. We make a list of the sub directories3. The marker becomes either: - InProgress `hashOfSubDirA/hashOfSubDirB/hashOfSubDirC` - TheEnd4. If the marker was of the type `InProgress`, the next request will make a list of the objects in `hashOfSubDirA`. And so on ...
-}
import Sources.Processing exposing (Marker(..))
separator : Stringseparator = " ɑ "
-- In
concat : List String -> Marker -> Markerconcat list marker = let result = case marker of InProgress m -> [ list, String.split separator m ] |> List.concat |> String.join separator
_ -> String.join separator list in case result of "" -> TheEnd
r -> InProgress r
-- Out
{-| Take the first item and return it.-}takeOne : Marker -> Maybe StringtakeOne marker = case marker of InProgress m -> m |> String.split separator |> List.head
_ -> Nothing
{-| Remove the first item if there is one.-}removeOne : Marker -> MarkerremoveOne marker = case marker of InProgress m -> let tmp = m |> String.split separator |> List.drop 1 |> String.join separator in case tmp of "" -> TheEnd
x -> InProgress x
_ -> TheEnd