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

Download and list entries in an SDMF directory

parent 1aa0ffc0
Branches
Tags
1 merge request!8Add `downloadDirectory` function!
...@@ -111,6 +111,7 @@ library ...@@ -111,6 +111,7 @@ library
, servant-client , servant-client
, servant-client-core , servant-client-core
, tahoe-chk , tahoe-chk
, tahoe-directory
, tahoe-great-black-swamp >=0.3 && <0.4 , tahoe-great-black-swamp >=0.3 && <0.4
, tahoe-ssk >=0.2 && <0.3 , tahoe-ssk >=0.2 && <0.3
, text , text
...@@ -189,14 +190,13 @@ executable list-dircap ...@@ -189,14 +190,13 @@ executable list-dircap
, gbs-downloader , gbs-downloader
, megaparsec , megaparsec
, tahoe-directory , tahoe-directory
, tahoe-ssk >=0.2 && <0.3 , tahoe-ssk >=0.2 && <0.3
, text , text
, yaml , yaml
hs-source-dirs: list-dircap hs-source-dirs: list-dircap
default-language: Haskell2010 default-language: Haskell2010
test-suite gbs-downloader-test test-suite gbs-downloader-test
-- Import common warning flags. -- Import common warning flags.
import: import:
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
module Main where module Main where
import qualified Data.ByteString as B 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 qualified Data.Text as T
import Data.Yaml (decodeEither') import Data.Yaml (decodeEither')
import System.Environment (getArgs) import System.Environment (getArgs)
...@@ -13,25 +10,24 @@ import Tahoe.Announcement (Announcements (..)) ...@@ -13,25 +10,24 @@ import Tahoe.Announcement (Announcements (..))
import qualified Tahoe.Directory as TD import qualified Tahoe.Directory as TD
import Text.Megaparsec (parse) import Text.Megaparsec (parse)
-- import Tahoe.Download (announcementToMutableStorageServer, download) import Tahoe.Download (announcementToMutableStorageServer, downloadDirectory)
main :: IO () main :: IO ()
main = do main = do
[announcementPath, dirReadCap] <- getArgs [announcementPath, dirReadCap] <- getArgs
-- Load server announcements -- Load server announcements
announcementsBytes <- B.readFile announcementPath announcementsBytes <- B.readFile announcementPath
let Right (Announcements _announcements) = decodeEither' announcementsBytes let Right (Announcements announcements) = decodeEither' announcementsBytes
-- Accept & parse read capability -- Accept & parse read capability
case parse TD.pReadSDMF "<argv>" (T.pack dirReadCap) of case parse TD.pReadSDMF "<argv>" (T.pack dirReadCap) of
Left e -> print $ "Failed to parse cap: " <> show e Left e -> print $ "Failed to parse cap: " <> show e
Right r -> print r Right r -> go announcements r
where
-- where go announcements cap = do
-- go announcements cap = do -- Download & decode the shares
-- -- Download & decode the shares result <- downloadDirectory announcements cap announcementToMutableStorageServer
-- result <- download announcements cap announcementToMutableStorageServer
-- Show the result
-- -- Show the result putStrLn "Your result:"
-- putStrLn "Your result:" either print print result
-- either print (C8.putStrLn . BL.toStrict) result
...@@ -10,6 +10,7 @@ module Tahoe.Download ( ...@@ -10,6 +10,7 @@ module Tahoe.Download (
DiscoverError (..), DiscoverError (..),
discoverShares, discoverShares,
download, download,
downloadDirectory,
announcementToImmutableStorageServer, announcementToImmutableStorageServer,
announcementToMutableStorageServer, announcementToMutableStorageServer,
getShareNumbers, getShareNumbers,
...@@ -28,6 +29,8 @@ import qualified Data.Set as Set ...@@ -28,6 +29,8 @@ import qualified Data.Set as Set
import Tahoe.Announcement (StorageServerAnnouncement) import Tahoe.Announcement (StorageServerAnnouncement)
import Tahoe.CHK.Server (StorageServer (..), StorageServerID) import Tahoe.CHK.Server (StorageServer (..), StorageServerID)
import Tahoe.CHK.Types (ShareNum, StorageIndex) import Tahoe.CHK.Types (ShareNum, StorageIndex)
import Tahoe.Directory (Directory, DirectoryCapability (DirectoryCapability))
import qualified Tahoe.Directory as Directory
import Tahoe.Download.Internal.Capability import Tahoe.Download.Internal.Capability
import Tahoe.Download.Internal.Client import Tahoe.Download.Internal.Client
import Tahoe.Download.Internal.Immutable import Tahoe.Download.Internal.Immutable
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment