summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-27 15:00:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-27 15:00:41 -0400
commit7bd7cca39932858a08dd50a15e5a6f2dc9daa6c0 (patch)
tree1b5e8aee02b7f06cc0b081dc7af334be18b3785e
parentd92730bef6cc40cdd96ff24957a9c2d2bc3cb730 (diff)
some work on the sha1 backend; still incomplete
-rw-r--r--Backend/SHA1.hs12
-rw-r--r--GitRepo.hs4
-rw-r--r--doc/todo/backendSHA1.mdwn4
3 files changed, 17 insertions, 3 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)
diff --git a/GitRepo.hs b/GitRepo.hs
index ee1bdba34..941810235 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 40ff868c2..fa9728af6 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.