diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-05-15 18:10:13 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-05-15 21:36:03 -0400 |
commit | 973180b077e60b5d12d7c57d926878d11d7f2105 (patch) | |
tree | 7d3bc5e651d330c1945c81f356b59eca90e73ea2 /Utility | |
parent | 0d85a42333484e1acb8e4942a619087768bc62fb (diff) |
stop using MissingH for MD5
Cryptonite is faster and allocates less, and I want to get rid of
MissingH use.
Note that the new dependency on memory is free; it's a dependency of
cryptonite.
This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/FileSystemEncoding.hs | 6 | ||||
-rw-r--r-- | Utility/Hash.hs | 6 | ||||
-rw-r--r-- | Utility/LockFile/PidLock.hs | 7 | ||||
-rw-r--r-- | Utility/Tuple.hs | 15 |
4 files changed, 21 insertions, 13 deletions
diff --git a/Utility/FileSystemEncoding.hs b/Utility/FileSystemEncoding.hs index ae3bd35d7..785b078ef 100644 --- a/Utility/FileSystemEncoding.hs +++ b/Utility/FileSystemEncoding.hs @@ -12,7 +12,6 @@ module Utility.FileSystemEncoding ( useFileSystemEncoding, fileEncoding, withFilePath, - md5FilePath, decodeBS, encodeBS, decodeW8, @@ -27,7 +26,6 @@ import qualified GHC.IO.Encoding as Encoding import Foreign.C import System.IO import System.IO.Unsafe -import qualified Data.Hash.MD5 as MD5 import Data.Word import Data.Bits.Utils import Data.List @@ -101,10 +99,6 @@ _encodeFilePath fp = unsafePerformIO $ do GHC.withCString enc fp (GHC.peekCString Encoding.char8) `catchNonAsync` (\_ -> return fp) -{- Encodes a FilePath into a Md5.Str, applying the filesystem encoding. -} -md5FilePath :: FilePath -> MD5.Str -md5FilePath = MD5.Str . _encodeFilePath - {- Decodes a ByteString into a FilePath, applying the filesystem encoding. -} decodeBS :: L.ByteString -> FilePath #ifndef mingw32_HOST_OS diff --git a/Utility/Hash.hs b/Utility/Hash.hs index b6bf996f8..70f826b7a 100644 --- a/Utility/Hash.hs +++ b/Utility/Hash.hs @@ -1,8 +1,4 @@ -{- Convenience wrapper around cryptohash/cryptonite. - - - - SHA3 hashes are currently only enabled when using cryptonite, - - because of https://github.com/vincenthz/hs-cryptohash/issues/36 - -} +{- Convenience wrapper around cryptonite's hashing. -} module Utility.Hash ( sha1, diff --git a/Utility/LockFile/PidLock.hs b/Utility/LockFile/PidLock.hs index 87c11c01c..23560fa57 100644 --- a/Utility/LockFile/PidLock.hs +++ b/Utility/LockFile/PidLock.hs @@ -25,6 +25,8 @@ import Utility.Path import Utility.FileMode import Utility.LockFile.LockStatus import Utility.ThreadScheduler +import Utility.Hash +import Utility.FileSystemEncoding import qualified Utility.LockFile.Posix as Posix import System.IO @@ -33,7 +35,6 @@ import Data.Maybe import Data.List import Network.BSD import System.FilePath -import Data.Hash.MD5 import Control.Applicative import Prelude @@ -99,7 +100,9 @@ sideLockFile lockfile = do f <- absPath lockfile let base = intercalate "_" (splitDirectories (makeRelative "/" f)) let shortbase = reverse $ take 32 $ reverse base - let md5sum = if base == shortbase then "" else md5s (Str base) + let md5sum = if base == shortbase + then "" + else show (md5 (encodeBS base)) dir <- ifM (doesDirectoryExist "/dev/shm") ( return "/dev/shm" , return "/tmp" diff --git a/Utility/Tuple.hs b/Utility/Tuple.hs new file mode 100644 index 000000000..78dd5d0c9 --- /dev/null +++ b/Utility/Tuple.hs @@ -0,0 +1,15 @@ +{- tuple utility functions + - + - Copyright 2017 Joey Hess <id@joeyh.name> + - + - License: BSD-2-clause + -} + +fst3 :: (a,b,c) -> a +fst3 (a,b,c) = a + +snd3 :: (a,b,c) -> b +snd3 (a,b,c) = b + +thd3 :: (a,b,c) -> c +thd3 (a,b,c) = c |