some work on the sha1 backend; still incomplete
This commit is contained in:
parent
d92730bef6
commit
7bd7cca399
3 changed files with 17 additions and 3 deletions
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
module Backend.SHA1 (backend) where
|
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 qualified Backend.File
|
||||||
import TypeInternals
|
import TypeInternals
|
||||||
|
|
||||||
|
@ -13,4 +18,9 @@ backend = Backend.File.backend {
|
||||||
|
|
||||||
-- checksum the file to get its key
|
-- checksum the file to get its key
|
||||||
keyValue :: FilePath -> Annex (Maybe 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)
|
||||||
|
|
|
@ -195,8 +195,8 @@ run repo params = assertLocal repo $ do
|
||||||
pipeRead :: Repo -> [String] -> IO String
|
pipeRead :: Repo -> [String] -> IO String
|
||||||
pipeRead repo params = assertLocal repo $ do
|
pipeRead repo params = assertLocal repo $ do
|
||||||
pOpen ReadFromPipe "git" (gitCommandLine repo params) $ \h -> do
|
pOpen ReadFromPipe "git" (gitCommandLine repo params) $ \h -> do
|
||||||
ret <- hGetContentsStrict h
|
ret <- hGetContentsStrict h
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
{- Passed a location, recursively scans for all files that
|
{- Passed a location, recursively scans for all files that
|
||||||
- are checked into git at that location. -}
|
- are checked into git at that location. -}
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
This backend is not finished.
|
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.
|
||||||
|
|
Loading…
Reference in a new issue