2010-11-09 19:59:49 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Lock where
|
|
|
|
|
|
|
|
import Control.Monad.State (liftIO)
|
|
|
|
import System.Directory
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Messages
|
|
|
|
import qualified Annex
|
|
|
|
import qualified GitRepo as Git
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
seek :: [CommandSeek]
|
2010-11-11 22:54:52 +00:00
|
|
|
seek = [withFilesUnlocked start]
|
|
|
|
|
2010-11-09 19:59:49 +00:00
|
|
|
{- Undo unlock -}
|
2010-12-30 18:19:16 +00:00
|
|
|
start :: CommandStartBackendFile
|
2010-11-11 21:58:55 +00:00
|
|
|
start (file, _) = do
|
|
|
|
showStart "lock" file
|
|
|
|
return $ Just $ perform file
|
2010-11-09 19:59:49 +00:00
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
perform :: FilePath -> CommandPerform
|
2010-11-09 19:59:49 +00:00
|
|
|
perform file = do
|
|
|
|
liftIO $ removeFile file
|
|
|
|
g <- Annex.gitRepo
|
2010-11-10 17:01:01 +00:00
|
|
|
-- first reset the file to drop any changes checked into the index
|
|
|
|
liftIO $ Git.run g ["reset", "-q", "--", file]
|
|
|
|
-- checkout the symlink
|
|
|
|
liftIO $ Git.run g ["checkout", "--", file]
|
2010-11-09 19:59:49 +00:00
|
|
|
return $ Just $ return True -- no cleanup needed
|