diff options
author | 2010-10-13 01:36:20 -0400 | |
---|---|---|
committer | 2010-10-13 01:36:20 -0400 | |
commit | 3e65384f06400e06f78173d64b13da07c5d024d7 (patch) | |
tree | 33633d58502174a989e3a1927811f33e30e5961b /Annex.hs | |
parent | 16cd682290b065fee59575b077525d20713e4b4b (diff) |
fix relative symlink 2
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -55,20 +55,30 @@ annexFile state file = do Nothing -> error $ "no backend could store: " ++ file Just (key, backend) -> setup key backend where + checkLegal file = do + s <- getSymbolicLinkStatus file + if ((isSymbolicLink s) || (not $ isRegularFile s)) + then error $ "not a regular file: " ++ file + else return () setup key backend = do let dest = annexLocation state backend key + let reldest = annexLocationRelative state backend key createDirectoryIfMissing True (parentDir dest) renameFile file dest - createSymbolicLink (annexLocationRelative state backend key) file + createSymbolicLink ((linkTarget file) ++ reldest) file gitRun (repo state) ["add", file] gitRun (repo state) ["commit", "-m", ("git-annex annexed " ++ file), file] logStatus state key ValuePresent - checkLegal file = do - s <- getSymbolicLinkStatus file - if ((isSymbolicLink s) || (not $ isRegularFile s)) - then error $ "not a regular file: " ++ file - else return () + linkTarget file = + -- relies on file being relative to the top of the + -- git repo; just replace each subdirectory with ".." + if (subdirs > 0) + then (join "/" $ take subdirs $ repeat "..") ++ "/" + else "" + where + subdirs = (length $ split "/" file) - 1 + {- Inverse of annexFile. -} unannexFile :: State -> FilePath -> IO () |