hashed-storage 0.4.4 → 0.4.5
raw patch · 4 files changed
+19/−15 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Storage.Hashed.Darcs: darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)
Files
- Bundled/SHA256.hs +3/−12
- Storage/Hashed/Darcs.hs +10/−1
- Storage/Hashed/Monad.hs +5/−1
- hashed-storage.cabal +1/−1
Bundled/SHA256.hs view
@@ -1,16 +1,8 @@ {-# LANGUAGE CPP, ForeignFunctionInterface #-} --- |--- Module: Data.Digest.SHA256--- Copyright: Zooko O'Whielacronx--- License: GPL------ Stability: experimental---- ByteString-based, zero-copying binding to Crypto++'s sha interface---- thanks to Don Stewart <dons@galois.com>, Matthew Sackman--- <matthew@wellquite.org>, Brian O'Sullivan, lispy, Adam Langley+-- Private interface to a C implementation of SHA 256. Originally based on code+-- by Zooko O'Whielacronx, but rewritten since. Therefore, BSD applies, as for+-- the rest of hashed-storage. module Bundled.SHA256 ( sha256 ) where @@ -27,6 +19,5 @@ return $! digest -- void sha256sum(const unsigned char *d, size_t n, unsigned char *md);--- foreign import ccall unsafe "sha2.h hashed_storage_sha256" c_sha256 :: Ptr CChar -> CSize -> Ptr Word8 -> IO ()
Storage/Hashed/Darcs.hs view
@@ -141,6 +141,14 @@ do hash <- sha256 <$> readBlob blob return $ File (Blob con hash) +darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)+darcsAddMissingHashes = updateTree update+ where update (SubTree t) = return . SubTree $ t { treeHash = darcsTreeHash t }+ update (File blob@(Blob con NoHash)) =+ do hash <- sha256 <$> readBlob blob+ return $ File (Blob con hash)+ update x = return x+ ------------------------------------------- -- Reading darcs pristine data --@@ -215,7 +223,8 @@ hashedTreeIO action t dir = do runTreeMonad action $ initialState t syncHashed where syncHashed ch = do- modify $ \st -> st { tree = darcsUpdateDirHashes $ tree st }+ hashed <- liftIO . darcsAddMissingHashes =<< gets tree+ modify $ \st -> st { tree = hashed } forM_ (reverse $ S.toList ch) $ \c -> do current <- gets tree case find current c of
Storage/Hashed/Monad.hs view
@@ -167,7 +167,11 @@ markChanged p maybeFlush where blob = File $ Blob (return con) hash- hash = sha256 con+ hash = NoHash -- we would like to say "sha256 con" here, but due+ -- to strictness of Hash in Blob, this would often+ -- lead to unnecessary computation which would then+ -- be discarded anyway; we rely on the sync+ -- implementation to fix up any NoHash occurrences createDirectory p = do expandTo p
hashed-storage.cabal view
@@ -1,5 +1,5 @@ name: hashed-storage-version: 0.4.4+version: 0.4.5 synopsis: Hashed file storage support code. description: Support code for reading and manipulating hashed file storage