diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-27 15:00:41 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-27 15:00:41 -0400 |
commit | 7bd7cca39932858a08dd50a15e5a6f2dc9daa6c0 (patch) | |
tree | 1b5e8aee02b7f06cc0b081dc7af334be18b3785e /Backend/SHA1.hs | |
parent | d92730bef6cc40cdd96ff24957a9c2d2bc3cb730 (diff) |
some work on the sha1 backend; still incomplete
Diffstat (limited to 'Backend/SHA1.hs')
-rw-r--r-- | Backend/SHA1.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Backend/SHA1.hs b/Backend/SHA1.hs index caece6b78..9e8d6df6d 100644 --- a/Backend/SHA1.hs +++ b/Backend/SHA1.hs @@ -3,6 +3,11 @@ module Backend.SHA1 (backend) where +import Control.Monad.State +import Data.String.Utils +import System.Cmd.Utils +import System.IO + import qualified Backend.File import TypeInternals @@ -13,4 +18,9 @@ backend = Backend.File.backend { -- checksum the file to get its key keyValue :: FilePath -> Annex (Maybe Key) -keyValue k = error "SHA1 keyValue unimplemented" -- TODO +keyValue file = liftIO $ pOpen ReadFromPipe "sha1sum" [file] $ \h -> do + line <- hGetLine h + let bits = split " " line + if (null bits) + then error "sha1sum parse error" + else return $ Just $ Key ((name backend), bits !! 0) |