diff options
author | 2010-10-10 15:21:17 -0400 | |
---|---|---|
committer | 2010-10-10 15:21:17 -0400 | |
commit | 4631927a5c7b14605725f1c6f272fee19d8b4318 (patch) | |
tree | 822809146873eaa07fa96f5ff2c6e4b31f3fd87c /Annex.hs | |
parent | cc235192353561a374c431485c6c3834659e0fa6 (diff) |
fix storing files in .git/annex by key
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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 |