diff --git a/Backend/SHA1.hs b/Backend/SHA1.hs index caece6b78c..9e8d6df6dd 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) diff --git a/GitRepo.hs b/GitRepo.hs index ee1bdba344..9418102355 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -195,8 +195,8 @@ run repo params = assertLocal repo $ do pipeRead :: Repo -> [String] -> IO String pipeRead repo params = assertLocal repo $ do pOpen ReadFromPipe "git" (gitCommandLine repo params) $ \h -> do - ret <- hGetContentsStrict h - return ret + ret <- hGetContentsStrict h + return ret {- Passed a location, recursively scans for all files that - are checked into git at that location. -} diff --git a/doc/todo/backendSHA1.mdwn b/doc/todo/backendSHA1.mdwn index 40ff868c22..fa9728af64 100644 --- a/doc/todo/backendSHA1.mdwn +++ b/doc/todo/backendSHA1.mdwn @@ -1 +1,5 @@ This backend is not finished. + +In particular, while files can be added using it, git-annex will not notice +when their content changes, and will not create a new key for the new sha1 +of the net content.