summaryrefslogtreecommitdiff
path: root/Backend/SHA.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-15 21:34:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-15 21:34:13 -0400
commit9d49fe2c172b135a1a3735827df014b5f45d99a2 (patch)
tree32caea71926c1b05d9b1921a16f364f57fc3e62f /Backend/SHA.hs
parent675ee89749ba2272d37b763078020b6e5f4cd380 (diff)
first pass at using new keys
It compiles. It sorta works. Several subcommands are FIXME marked and broken, because things that used to accept separate --backend and --key params need to be changed to accept just a --key that encodes all the key info, now that there is metadata in keys.
Diffstat (limited to 'Backend/SHA.hs')
-rw-r--r--Backend/SHA.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs
index 4eea890ce..3cdc3bf80 100644
--- a/Backend/SHA.hs
+++ b/Backend/SHA.hs
@@ -13,6 +13,7 @@ import System.Cmd.Utils
import System.IO
import System.Directory
import Data.Maybe
+import System.Posix.Files
import qualified Backend.File
import BackendTypes
@@ -23,6 +24,7 @@ import Content
import Types
import Utility
import qualified SysConfig
+import Key
type SHASize = Int
@@ -63,11 +65,16 @@ shaN size file = do
where
command = "sha" ++ (show size) ++ "sum"
--- A key is a checksum of its contents.
+{- A key is a checksum of its contents. -}
keyValue :: SHASize -> FilePath -> Annex (Maybe Key)
keyValue size file = do
s <- shaN size file
- return $ Just $ Key (shaName size, s)
+ stat <- liftIO $ getFileStatus file
+ return $ Just $ stubKey {
+ keyName = s,
+ keyBackendName = shaName size,
+ keySize = Just $ fromIntegral $ fileSize stat
+ }
-- A key's checksum is checked during fsck.
checkKeyChecksum :: SHASize -> Key -> Annex Bool