add ContentSource type, for remotes that act on files rather than ByteStrings

Note that currently nothing cleans up a ContentSource's file, when eg,
retrieving chunks.
This commit is contained in:
Joey Hess 2014-07-29 14:53:17 -04:00
parent 216fdbd6bd
commit f5af470875
5 changed files with 102 additions and 49 deletions

View file

@ -110,9 +110,9 @@ tmpDir d k = addTrailingPathSeparator $ d </> "tmp" </> keyFile k
prepareStore :: FilePath -> ChunkConfig -> Preparer Storer
prepareStore d chunkconfig = checkPrepare
(\k -> checkDiskSpace (Just d) k 0)
(store d chunkconfig)
(byteStorer $ store d chunkconfig)
store :: FilePath -> ChunkConfig -> Storer
store :: FilePath -> ChunkConfig -> Key -> L.ByteString -> MeterUpdate -> IO Bool
store d chunkconfig k b p = do
void $ tryIO $ createDirectoryIfMissing True tmpdir
case chunkconfig of
@ -137,7 +137,8 @@ store d chunkconfig k b p = do
retrieve :: FilePath -> ChunkConfig -> Preparer Retriever
retrieve d (LegacyChunks _) = Legacy.retrieve locations d
retrieve d _ = simplyPrepare $ \k -> L.readFile =<< getLocation d k
retrieve d _ = simplyPrepare $ byteRetriever $
\k -> L.readFile =<< getLocation d k
retrieveCheap :: FilePath -> ChunkConfig -> Key -> FilePath -> Annex Bool
-- no cheap retrieval possible for chunks