diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-05 19:51:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-05 19:51:03 -0400 |
commit | d3cee987caf20b309334b37bd1b89e8b9115cf0a (patch) | |
tree | 8c1a244545efed3b2fd9e48ea28faac12aa326fe /Backend/SHA.hs | |
parent | 77188ff04d8d4d42b25daac9eeffbf10d8b663ac (diff) |
separate source of content from the filename associated with the key when generating a key
This already made migrate's code a lot simpler.
Diffstat (limited to 'Backend/SHA.hs')
-rw-r--r-- | Backend/SHA.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs index c2a6cf976..df613bbcd 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -69,9 +69,10 @@ shaN size file = do command = fromJust $ shaCommand size {- A key is a checksum of its contents. -} -keyValue :: SHASize -> FilePath -> Annex (Maybe Key) -keyValue size file = do - s <- shaN size file +keyValue :: SHASize -> KeySource -> Annex (Maybe Key) +keyValue size source = do + let file = contentLocation source + s <- shaN size file stat <- liftIO $ getFileStatus file return $ Just $ stubKey { keyName = s @@ -80,14 +81,14 @@ keyValue size file = do } {- Extension preserving keys. -} -keyValueE :: SHASize -> FilePath -> Annex (Maybe Key) -keyValueE size file = keyValue size file >>= maybe (return Nothing) addE +keyValueE :: SHASize -> KeySource -> Annex (Maybe Key) +keyValueE size source = keyValue size source >>= maybe (return Nothing) addE where addE k = return $ Just $ k { keyName = keyName k ++ extension , keyBackendName = shaNameE size } - naiveextension = takeExtension file + naiveextension = takeExtension $ keyFilename source extension -- long or newline containing extensions are -- probably not really an extension |