Recover original indentation

This commit is contained in:
Victor Denisov 2018-01-27 11:46:53 -08:00
parent 582a16d08e
commit 77b84a5695
2 changed files with 22 additions and 21 deletions

View file

@ -46,7 +46,7 @@ defaultChunkSize :: Int64
-- ^ The default chunk size is 256 kB -- ^ The default chunk size is 256 kB
defaultChunkSize = 256 * 1024 defaultChunkSize = 256 * 1024
-- magic constant for the -- magic constant for md5Finalize
md5BlockSizeInBytes :: Int md5BlockSizeInBytes :: Int
md5BlockSizeInBytes = 64 md5BlockSizeInBytes = 64
@ -159,26 +159,25 @@ finalizeMD5 ctx rest =
-- Write as many chunks as can be written from the file writer -- Write as many chunks as can be written from the file writer
writeChunks :: (Monad m, MonadIO m) => FileWriter -> L.ByteString -> Action m FileWriter writeChunks :: (Monad m, MonadIO m) => FileWriter -> L.ByteString -> Action m FileWriter
writeChunks (FileWriter chunkSize bucket files_id i size acc md5context md5acc) chunk = writeChunks (FileWriter chunkSize bucket files_id i size acc md5context md5acc) chunk = do
do -- Update md5 context
-- Update md5 context let md5BlockLength = fromIntegral $ untag (blockLength :: Tagged MD5Digest Int)
let md5BlockLength = fromIntegral $ untag (blockLength :: Tagged MD5Digest Int) let md5acc_temp = (md5acc `L.append` chunk)
let md5acc_temp = (md5acc `L.append` chunk) let (md5context', md5acc') =
let (md5context', md5acc') = if (L.length md5acc_temp < md5BlockLength)
if (L.length md5acc_temp < md5BlockLength) then (md5context, md5acc_temp)
then (md5context, md5acc_temp) else let numBlocks = L.length md5acc_temp `div` md5BlockLength
else let numBlocks = L.length md5acc_temp `div` md5BlockLength (current, rest) = L.splitAt (md5BlockLength * numBlocks) md5acc_temp
(current, rest) = L.splitAt (md5BlockLength * numBlocks) md5acc_temp in (md5Update md5context (L.toStrict current), rest)
in (md5Update md5context (L.toStrict current), rest) -- Update chunks
-- Update chunks let size' = (size + L.length chunk)
let size' = (size + L.length chunk) let acc_temp = (acc `L.append` chunk)
let acc_temp = (acc `L.append` chunk) if (L.length acc_temp < chunkSize)
if (L.length acc_temp < chunkSize) then return (FileWriter chunkSize bucket files_id i size' acc_temp md5context' md5acc')
then return (FileWriter chunkSize bucket files_id i size' acc_temp md5context' md5acc') else do
else do let (chunk, acc') = L.splitAt chunkSize acc_temp
let (chunk, acc') = L.splitAt chunkSize acc_temp putChunk bucket files_id i chunk
putChunk bucket files_id i chunk writeChunks (FileWriter chunkSize bucket files_id (i+1) size' acc' md5context' md5acc') L.empty
writeChunks (FileWriter chunkSize bucket files_id (i+1) size' acc' md5context' md5acc') L.empty
sinkFile :: (Monad m, MonadIO m) => Bucket -> Text -> Consumer S.ByteString (Action m) File sinkFile :: (Monad m, MonadIO m) => Bucket -> Text -> Consumer S.ByteString (Action m) File
-- ^ A consumer that creates a file in the bucket and puts all consumed data in it -- ^ A consumer that creates a file in the bucket and puts all consumed data in it

View file

@ -1,6 +1,8 @@
version: '3' version: '3'
services: services:
mongodb: mongodb:
ports:
- 27017:27017
image: mongo:3.4.3 image: mongo:3.4.3
mongodb-haskell: mongodb-haskell:
image: phadej/ghc:8.0.2 image: phadej/ghc:8.0.2