Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- hashStore :: FilePath -> (ByteString -> IO ByteString) -> (String, ByteString) -> IO String
- hashStoreWithContent :: FilePath -> (ByteString -> IO ByteString) -> (String, ByteString) -> IO (String, ByteString)
Documentation
:: FilePath | Directory to store file contents with new hash |
-> (ByteString -> IO ByteString) | Action to be performed if hash is different |
-> (String, ByteString) | File name |
-> IO String | File name with hash |
computes hashStore
storePath action (name, content)hash
of content
and performs action
if file storePath/hash-name
doesn't exist, writing new
content in this file.
The property is that for any item (name, hash)
, we get a valid filepath by
storePath/hash-name
.
This functions solves the following problem. The caller doesn't need the content. Then it is better not to return the bytestring (we avoid the overhrad of reading the file in the cache hit case).
:: FilePath | Directory to store file contents with new hash |
-> (ByteString -> IO ByteString) | Action to be performed if hash is different |
-> (String, ByteString) | File name |
-> IO (String, ByteString) | File name with hash and content of file |
Like hashStore
but also returns file content of hashed file.
This functions solves the following problem. The caller needs the file content. Then it's better to return the bytestring (we avoid the overhead of reading the file in the cache miss case).