summaryrefslogtreecommitdiffhomepage
path: root/Storage.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-17 15:23:00 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-17 15:23:00 -0400
commit41bfb68ee296a4ecdcbd9c02d242d6c9e149b7b8 (patch)
tree55e456e9e56cdc1c584c1a090536a05eec791495 /Storage.hs
parente32b20fe15175136bc98b25a002c5acc495679eb (diff)
downloadkeysafe-41bfb68ee296a4ecdcbd9c02d242d6c9e149b7b8.tar.gz
make storage to use configurable on command line
Diffstat (limited to 'Storage.hs')
-rw-r--r--Storage.hs15
1 files changed, 15 insertions, 0 deletions
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