diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-09 15:59:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-09 15:59:49 -0400 |
commit | 536bc97d25479ac969273b49442c2fd8c31358c4 (patch) | |
tree | aeb19878fd34ff88e69f0f1c3faa019e8cc180c5 /Command/Unlock.hs | |
parent | d56feda25dd82ffa34fe5e3f28eff3ecf9eac5b5 (diff) |
lock and unlock subcommands
Diffstat (limited to 'Command/Unlock.hs')
-rw-r--r-- | Command/Unlock.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Command/Unlock.hs b/Command/Unlock.hs new file mode 100644 index 000000000..57d4ad87a --- /dev/null +++ b/Command/Unlock.hs @@ -0,0 +1,36 @@ +{- git-annex command + - + - Copyright 2010 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Unlock where + +import Control.Monad.State (liftIO) +import System.Directory + +import Command +import qualified Annex +import Types +import Messages +import Locations +import Utility + +{- The unlock subcommand replaces the symlink with a copy of the file's + - content. -} +start :: SubCmdStartString +start file = isAnnexed file $ \(key, _) -> do + showStart "unlock" file + return $ Just $ perform file key + +perform :: FilePath -> Key -> SubCmdPerform +perform dest key = do + g <- Annex.gitRepo + let src = annexLocation g key + liftIO $ removeFile dest + showNote "copying..." + ok <- liftIO $ boolSystem "cp" ["-p", src, dest] + if ok + then return $ Just $ return True -- no cleanup needed + else error "cp failed!" |