diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-10 19:53:31 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-10 19:53:31 -0400 |
commit | 344f13394fe5b12cbdd5eeb99bb63892c7096bfd (patch) | |
tree | 478ad78d49e9c3515bee1cd2afd24d3e435a19eb /Annex.hs | |
parent | 93d2dc0d6878ccb1067376d2a03193c222429d3e (diff) |
update
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -44,14 +44,30 @@ annexFile state file = do gitAdd (repo state) file checkExists file = do exists <- doesFileExist file - case (exists) of - False -> error $ "does not exist: " ++ file - True -> return () + if (not exists) + then error $ "does not exist: " ++ file + else return () checkLegal file = do - s <- getFileStatus file - case (not (isSymbolicLink s) && not (isRegularFile s)) of - False -> error $ "not a regular file: " ++ file - True -> return () + s <- getSymbolicLinkStatus file + if ((isSymbolicLink s) || (not $ isRegularFile s)) + then error $ "not a regular file: " ++ file + else return () + +{- Inverse of annexFile. -} +unannexFile :: State -> FilePath -> IO () +unannexFile state file = do + alreadyannexed <- lookupBackend (backends state) (repo state) file + case (alreadyannexed) of + Nothing -> error $ "not annexed " ++ file + Just _ -> do + mkey <- dropFile (backends state) (repo state) file + case (mkey) of + Nothing -> return () + Just key -> do + src <- annexDir (repo state) key + removeFile file + renameFile src file + return () {- Sets up a git repo for git-annex. May be called repeatedly. -} gitPrep :: GitRepo -> IO () |