blob: 9e8d6df6dd641158f1c087562613ef82adcb4279 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{- git-annex "SHA1" backend
- -}
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
backend = Backend.File.backend {
name = "SHA1",
getKey = keyValue
}
-- checksum the file to get its key
keyValue :: FilePath -> Annex (Maybe Key)
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)
|