aboutsummaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-10 19:53:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-10 19:53:31 -0400
commit344f13394fe5b12cbdd5eeb99bb63892c7096bfd (patch)
tree478ad78d49e9c3515bee1cd2afd24d3e435a19eb /Annex.hs
parent93d2dc0d6878ccb1067376d2a03193c222429d3e (diff)
update
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs30
1 files changed, 23 insertions, 7 deletions
diff --git a/Annex.hs b/Annex.hs
index 402c767da..964532f3f 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -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 ()