Update shadowing warnings.
This commit is contained in:
parent
b094dff057
commit
74a40411c1
1 changed files with 10 additions and 10 deletions
|
@ -136,10 +136,10 @@ finalizeFile :: (Monad m, MonadIO m) => Text -> FileWriter -> Action m File
|
||||||
finalizeFile filename (FileWriter chunkSize bucket files_id i size acc md5context md5acc) = do
|
finalizeFile filename (FileWriter chunkSize bucket files_id i size acc md5context md5acc) = do
|
||||||
let md5digest = finalizeMD5 md5context (L.toStrict md5acc)
|
let md5digest = finalizeMD5 md5context (L.toStrict md5acc)
|
||||||
when (L.length acc > 0) $ putChunk bucket files_id i acc
|
when (L.length acc > 0) $ putChunk bucket files_id i acc
|
||||||
timestamp <- liftIO $ getCurrentTime
|
currentTimestamp <- liftIO $ getCurrentTime
|
||||||
let doc = [ "_id" =: files_id
|
let doc = [ "_id" =: files_id
|
||||||
, "length" =: size
|
, "length" =: size
|
||||||
, "uploadDate" =: timestamp
|
, "uploadDate" =: currentTimestamp
|
||||||
, "md5" =: show (md5digest)
|
, "md5" =: show (md5digest)
|
||||||
, "chunkSize" =: chunkSize
|
, "chunkSize" =: chunkSize
|
||||||
, "filename" =: filename
|
, "filename" =: filename
|
||||||
|
@ -149,13 +149,13 @@ finalizeFile filename (FileWriter chunkSize bucket files_id i size acc md5contex
|
||||||
|
|
||||||
-- finalize the remainder and return the MD5Digest.
|
-- finalize the remainder and return the MD5Digest.
|
||||||
finalizeMD5 :: MD5Context -> S.ByteString -> MD5Digest
|
finalizeMD5 :: MD5Context -> S.ByteString -> MD5Digest
|
||||||
finalizeMD5 ctx rest =
|
finalizeMD5 ctx remainder =
|
||||||
md5Finalize ctx2 (S.drop lu rest) -- can only handle max md5BlockSizeInBytes length
|
md5Finalize ctx2 (S.drop lu remainder) -- can only handle max md5BlockSizeInBytes length
|
||||||
where
|
where
|
||||||
l = S.length rest
|
l = S.length remainder
|
||||||
r = l `mod` md5BlockSizeInBytes
|
r = l `mod` md5BlockSizeInBytes
|
||||||
lu = l - r
|
lu = l - r
|
||||||
ctx2 = md5Update ctx (S.take lu rest)
|
ctx2 = md5Update ctx (S.take lu remainder)
|
||||||
|
|
||||||
-- 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
|
||||||
|
@ -167,16 +167,16 @@ writeChunks (FileWriter chunkSize bucket files_id i size acc 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, remainder) = L.splitAt (md5BlockLength * numBlocks) md5acc_temp
|
||||||
in (md5Update md5context (L.toStrict current), rest)
|
in (md5Update md5context (L.toStrict current), remainder)
|
||||||
-- 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 (newChunk, acc') = L.splitAt chunkSize acc_temp
|
||||||
putChunk bucket files_id i chunk
|
putChunk bucket files_id i newChunk
|
||||||
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 -> ConduitT S.ByteString o (Action m) File
|
sinkFile :: (Monad m, MonadIO m) => Bucket -> Text -> ConduitT S.ByteString o (Action m) File
|
||||||
|
|
Loading…
Reference in a new issue