summaryrefslogtreecommitdiff
path: root/Types/StoreRetrieve.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Types/StoreRetrieve.hs')
-rw-r--r--Types/StoreRetrieve.hs27
1 files changed, 4 insertions, 23 deletions
diff --git a/Types/StoreRetrieve.hs b/Types/StoreRetrieve.hs
index dfee20758..0ee2fd501 100644
--- a/Types/StoreRetrieve.hs
+++ b/Types/StoreRetrieve.hs
@@ -1,4 +1,4 @@
-{- Types for Storer and Retriever
+{- Types for Storer and Retriever actions for remotes.
-
- Copyright 2014 Joey Hess <joey@kitenet.net>
-
@@ -10,7 +10,6 @@
module Types.StoreRetrieve where
import Common.Annex
-import Annex.Content
import Utility.Metered
import qualified Data.ByteString.Lazy as L
@@ -28,25 +27,7 @@ data ContentSource
-- Can throw exceptions.
type Storer = Key -> ContentSource -> MeterUpdate -> Annex Bool
--- Action that retrieves a Key's content from a remote.
+-- Action that retrieves a Key's content from a remote, passing it to a
+-- callback.
-- Throws exception if key is not present, or remote is not accessible.
-type Retriever = Key -> MeterUpdate -> Annex ContentSource
-
-fileStorer :: (Key -> FilePath -> MeterUpdate -> Annex Bool) -> Storer
-fileStorer a k (FileContent f) m = a k f m
-fileStorer a k (ByteContent b) m = withTmp k $ \tmp -> do
- liftIO $ L.writeFile tmp b
- a k tmp m
-
-byteStorer :: (Key -> L.ByteString -> MeterUpdate -> Annex Bool) -> Storer
-byteStorer a k c m = withBytes c $ \b -> a k b m
-
-fileRetriever :: (Key -> MeterUpdate -> Annex FilePath) -> Retriever
-fileRetriever a k m = FileContent <$> a k m
-
-byteRetriever :: (Key -> Annex L.ByteString) -> Retriever
-byteRetriever a k _m = ByteContent <$> a k
-
-withBytes :: ContentSource -> (L.ByteString -> Annex a) -> Annex a
-withBytes (ByteContent b) a = a b
-withBytes (FileContent f) a = a =<< liftIO (L.readFile f)
+type Retriever = Key -> MeterUpdate -> (ContentSource -> Annex Bool) -> Annex Bool