summaryrefslogtreecommitdiff
path: root/Command/SetKey.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-26 00:17:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-26 00:17:38 -0400
commit6a97b10fcb3e1fa6a230d92a25b42ded587ff743 (patch)
treeb8a6ce70916c397c67788b47de6a389db8753969 /Command/SetKey.hs
parent082b022f9ae56b1446b6607cf7851cd4f1d4f904 (diff)
rework config storage
Moved away from a map of flags to storing config directly in the AnnexState structure. Got rid of most accessor functions in Annex. This allowed supporting multiple --exclude flags.
Diffstat (limited to 'Command/SetKey.hs')
-rw-r--r--Command/SetKey.hs26
1 files changed, 10 insertions, 16 deletions
diff --git a/Command/SetKey.hs b/Command/SetKey.hs
index 412504b2e..388392cd6 100644
--- a/Command/SetKey.hs
+++ b/Command/SetKey.hs
@@ -8,14 +8,10 @@
module Command.SetKey where
import Control.Monad.State (liftIO)
-import Control.Monad (when)
import Command
-import qualified Annex
import Utility
-import qualified Backend
import LocationLog
-import Types
import Content
import Messages
@@ -29,26 +25,24 @@ seek = [withTempFile start]
{- Sets cached content for a key. -}
start :: CommandStartString
start file = do
- keyname <- Annex.flagGet "key"
- when (null keyname) $ error "please specify the key with --key"
- backends <- Backend.list
- let key = genKey (head backends) keyname
showStart "setkey" file
- return $ Just $ perform file key
-perform :: FilePath -> Key -> CommandPerform
-perform file key = do
+ return $ Just $ perform file
+
+perform :: FilePath -> CommandPerform
+perform file = do
+ key <- cmdlineKey
-- the file might be on a different filesystem, so mv is used
- -- rather than simply calling moveToObjectDir key file
+ -- rather than simply calling moveToObjectDir
ok <- getViaTmp key $ \dest -> do
if dest /= file
then liftIO $ boolSystem "mv" [file, dest]
else return True
if ok
- then return $ Just $ cleanup key
+ then return $ Just $ cleanup
else error "mv failed!"
-cleanup :: Key -> CommandCleanup
-cleanup key = do
+cleanup :: CommandCleanup
+cleanup = do
+ key <- cmdlineKey
logStatus key ValuePresent
return True
-