diff options
author | Joey Hess <joey@kitenet.net> | 2014-08-09 14:23:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-08-09 14:26:19 -0400 |
commit | bd5de3ff4b50f6e90f6bb638d32fb60472ca8e47 (patch) | |
tree | 1189c0204ed676fdca09d88876eac3bf6a692df6 /Remote/Helper | |
parent | d03284c66e5f356421da06a17bf0e71d7b205157 (diff) |
S3: convert to aws for store, remove, checkPresent
Fixes the memory leak on store.. the second oldest open git-annex bug!
Only retrieve remains to be converted.
This commit was sponsored by Scott Robinson.
Diffstat (limited to 'Remote/Helper')
-rw-r--r-- | Remote/Helper/Http.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Remote/Helper/Http.hs b/Remote/Helper/Http.hs index f1d576d1c..4088854ff 100644 --- a/Remote/Helper/Http.hs +++ b/Remote/Helper/Http.hs @@ -24,14 +24,18 @@ import Control.Concurrent -- Implemented as a fileStorer, so that the content can be streamed -- from the file in constant space. httpStorer :: (Key -> RequestBody -> Annex Bool) -> Storer -httpStorer a = fileStorer $ \k f m -> do - size <- liftIO $ (fromIntegral . fileSize <$> getFileStatus f :: IO Integer) - let streamer sink = withMeteredFile f m $ \b -> do +httpStorer a = fileStorer $ \k f m -> a k =<< liftIO (httpBodyStorer f m) + +-- Reads the file and generates a streaming request body, that will update +-- the meter as it's sent. +httpBodyStorer :: FilePath -> MeterUpdate -> IO RequestBody +httpBodyStorer src m = do + size <- fromIntegral . fileSize <$> getFileStatus src :: IO Integer + let streamer sink = withMeteredFile src m $ \b -> do mvar <- newMVar $ L.toChunks b let getnextchunk = modifyMVar mvar $ pure . pop sink getnextchunk - let body = RequestBodyStream (fromInteger size) streamer - a k body + return $ RequestBodyStream (fromInteger size) streamer where pop [] = ([], S.empty) pop (c:cs) = (cs, c) |