some work on the sha1 backend; still incomplete

This commit is contained in:
Joey Hess 2010-10-27 15:00:41 -04:00
parent d92730bef6
commit 7bd7cca399
3 changed files with 17 additions and 3 deletions

View file

@ -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)

View file

@ -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. -}

View file

@ -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.