broke subcommands out into separate modules
This commit is contained in:
parent
606ed6bb35
commit
0eae5b806c
14 changed files with 780 additions and 556 deletions
40
Command/Fix.hs
Normal file
40
Command/Fix.hs
Normal file
|
@ -0,0 +1,40 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Command.Fix where
|
||||
|
||||
import Control.Monad.State (liftIO)
|
||||
import System.Posix.Files
|
||||
import System.Directory
|
||||
|
||||
import Command
|
||||
import qualified Annex
|
||||
import Utility
|
||||
import Core
|
||||
|
||||
{- Fixes the symlink to an annexed file. -}
|
||||
start :: SubCmdStartString
|
||||
start file = isAnnexed file $ \(key, _) -> do
|
||||
link <- calcGitLink file key
|
||||
l <- liftIO $ readSymbolicLink file
|
||||
if (link == l)
|
||||
then return Nothing
|
||||
else do
|
||||
showStart "fix" file
|
||||
return $ Just $ perform file link
|
||||
|
||||
perform :: FilePath -> FilePath -> SubCmdPerform
|
||||
perform file link = do
|
||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||
liftIO $ removeFile file
|
||||
liftIO $ createSymbolicLink link file
|
||||
return $ Just $ cleanup file
|
||||
|
||||
cleanup :: FilePath -> SubCmdCleanup
|
||||
cleanup file = do
|
||||
Annex.queue "add" [] file
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue