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

Add a demo app that downloads SDMF

parent 5c2384ff
No related branches found
No related tags found
1 merge request!5Support SDMF in the `download` API
Pipeline #4691 failed
......@@ -7,8 +7,8 @@ It aims for bit-for-bit compatibility with the original Python implementation.
### What is the current state?
It's just starting.
It can't do much.
* It can download immutable and mutable shares from Great Black Swamp storage servers.
* It can interpret, decode, and decrypt the data for CHK- and SDMF-encoded shares to recover the plaintext.
## Why does it exist?
......
module Main where
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C8
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text as T
import Data.Yaml (decodeEither')
import System.Environment (getArgs)
import Tahoe.Announcement (Announcements (..))
import Tahoe.Download (announcementToMutableStorageServer, download)
import Tahoe.SDMF (SDMF (..), pCapability, writerReader)
import Text.Megaparsec (parse)
main :: IO ()
main = do
[announcementPath, readCap] <- getArgs
-- Load server announcements
announcementsBytes <- B.readFile announcementPath
let Right (Announcements announcements) = decodeEither' announcementsBytes
-- Accept & parse read capability
case parse pCapability "<argv>" (T.pack readCap) of
Left e -> print $ "Failed to parse cap: " <> show e
Right (SDMFVerifier _) -> C8.putStrLn "Nothing currently implemented for verifier caps."
Right (SDMFWriter rwcap) -> go announcements (writerReader rwcap)
Right (SDMFReader rocap) -> go announcements rocap
where
go announcements cap = do
-- Download & decode the shares
result <- download announcements cap announcementToMutableStorageServer
-- Show the result
putStrLn "Your result:"
either print (C8.putStrLn . BL.toStrict) result
......@@ -155,6 +155,26 @@ executable gbs-download-chk
-- Base language which the package is written in.
default-language: Haskell2010
executable gbs-download-sdmf
import:
warnings
, language
main-is: Main.hs
build-depends:
, aeson
, base
, bytestring
, containers
, gbs-downloader
, megaparsec
, tahoe-ssk
, text
, yaml
hs-source-dirs: download-sdmf
default-language: Haskell2010
test-suite gbs-downloader-test
-- Import common warning flags.
import:
......
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