From 41bfb68ee296a4ecdcbd9c02d242d6c9e149b7b8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 17 Aug 2016 15:23:00 -0400 Subject: make storage to use configurable on command line --- Storage.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Storage.hs') diff --git a/Storage.hs b/Storage.hs index d13cbfe..d1a3ad8 100644 --- a/Storage.hs +++ b/Storage.hs @@ -6,6 +6,7 @@ module Storage where import Types +import Shard data Storage = Storage { storeShard :: StorableObjectIdent -> Shard -> IO StoreResult @@ -26,3 +27,17 @@ data ObscureResult = ObscureSuccess | ObscureFailure String data CountResult = CountResult Integer | CountFailure String deriving (Show) + +storeShards :: Storage -> ShardIdents -> [(IO (), Shard)] -> IO StoreResult +storeShards storage sis shards = do + r <- go (zip (getIdents sis) shards) + _ <- obscureShards storage + return r + where + go [] = return StoreSuccess + go ((i,(showprogress, s)):rest) = do + r <- storeShard storage i s + _ <- showprogress + case r of + StoreSuccess -> go rest + _ -> return r -- cgit v1.2.3