summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-10 15:21:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-10 15:21:17 -0400
commit4631927a5c7b14605725f1c6f272fee19d8b4318 (patch)
tree822809146873eaa07fa96f5ff2c6e4b31f3fd87c /Annex.hs
parentcc235192353561a374c431485c6c3834659e0fa6 (diff)
fix storing files in .git/annex by key
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs19
1 files changed, 9 insertions, 10 deletions
diff --git a/Annex.hs b/Annex.hs
index 7d89c882a..bd9ce92a4 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -9,14 +9,13 @@ import System.Directory
import GitRepo
import Utility
-{- An annexed file's content is stored in .git/annex/. -}
-annexedFileLocation repo file = do
+{- An annexed file's content is stored somewhere under .git/annex/ -}
+annexLoc repo key = do
dir <- gitDir repo
- return $ dir ++ "/annex/" ++ (gitRelative repo file)
+ return $ dir ++ "/annex/" ++ key
{- Annexes a file, storing it in a backend, and then moving it into
- - the annex directory and setting up the symlink pointing to its
- - content. -}
+ - the annex directory and setting up the symlink pointing to its content. -}
annexFile :: [Backend] -> GitRepo -> FilePath -> IO ()
annexFile backends repo file = do
alreadyannexed <- lookupBackend backends repo file
@@ -24,12 +23,12 @@ annexFile backends repo file = do
Just _ -> error $ "already annexed " ++ file
Nothing -> do
stored <- storeFile backends repo file
- if (not stored)
- then error $ "no backend could store " ++ file
- else symlink
+ case (stored) of
+ Nothing -> error $ "no backend could store " ++ file
+ Just key -> symlink key
where
- symlink = do
- dest <- annexedFileLocation repo file
+ symlink key = do
+ dest <- annexLoc repo key
createDirectoryIfMissing True (parentDir dest)
renameFile file dest
createSymbolicLink dest file