diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-16 23:16:18 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-16 23:16:18 -0400 |
commit | 039e3ffdfad86fa4e39ca777273be65a7be893db (patch) | |
tree | ee10649fbc59636b6d0911d6a40440e0c8b74612 /Remote/Directory.hs | |
parent | 373a90aa69eef415b1ec00740dce9f729f8c6b19 (diff) |
webdav now checks presence of and receives chunked content
Note that receiving encrypted chunked content currently involves buffering.
(So does doing so with the directory special remote.)
Diffstat (limited to 'Remote/Directory.hs')
-rw-r--r-- | Remote/Directory.hs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/Remote/Directory.hs b/Remote/Directory.hs index 6bf725379..794a8c468 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -89,7 +89,7 @@ withCheckedFiles check (Just _) d k a = go $ locations d k let chunkcount = f ++ chunkCount ifM (check chunkcount) ( do - chunks <- getChunks f <$> readFile chunkcount + chunks <- listChunks f <$> readFile chunkcount ifM (all id <$> mapM check chunks) ( a chunks , return False ) , go fs @@ -155,29 +155,6 @@ storeSplit' meterupdate chunksize (d:dests) bs c = do feed (sz - s) ls h else return (l:ls) -{- Write a L.ByteString to a file, updating a progress meter - - after each chunk of the L.ByteString, typically every 64 kb or so. -} -meteredWriteFile :: MeterUpdate -> FilePath -> L.ByteString -> IO () -meteredWriteFile meterupdate dest b = - meteredWriteFile' meterupdate dest (L.toChunks b) feeder - where - feeder chunks = return ([], chunks) - -{- Writes a series of S.ByteString chunks to a file, updating a progress - - meter after each chunk. The feeder is called to get more chunks. -} -meteredWriteFile' :: MeterUpdate -> FilePath -> s -> (s -> IO (s, [S.ByteString])) -> IO () -meteredWriteFile' meterupdate dest startstate feeder = - E.bracket (openFile dest WriteMode) hClose (feed startstate []) - where - feed state [] h = do - (state', cs) <- feeder state - unless (null cs) $ - feed state' cs h - feed state (c:cs) h = do - S.hPut h c - meterupdate $ toInteger $ S.length c - feed state cs h - storeHelper :: FilePath -> ChunkSize -> Key -> ([FilePath] -> IO [FilePath]) -> Annex Bool storeHelper d chunksize key storer = check <&&> go where @@ -203,7 +180,7 @@ retrieve :: FilePath -> ChunkSize -> Key -> AssociatedFile -> FilePath -> Annex retrieve d chunksize k _ f = metered Nothing k $ \meterupdate -> liftIO $ withStoredFiles chunksize d k $ \files -> catchBoolIO $ do - meteredWriteFile' meterupdate f files feeder + meteredWriteFileChunks meterupdate f files feeder return True where feeder [] = return ([], []) |