fix relative symlink 2
This commit is contained in:
parent
16cd682290
commit
3e65384f06
2 changed files with 21 additions and 10 deletions
28
Annex.hs
28
Annex.hs
|
@ -55,20 +55,30 @@ annexFile state file = do
|
||||||
Nothing -> error $ "no backend could store: " ++ file
|
Nothing -> error $ "no backend could store: " ++ file
|
||||||
Just (key, backend) -> setup key backend
|
Just (key, backend) -> setup key backend
|
||||||
where
|
where
|
||||||
setup key backend = do
|
|
||||||
let dest = annexLocation state backend key
|
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
|
||||||
renameFile file dest
|
|
||||||
createSymbolicLink (annexLocationRelative state backend key) file
|
|
||||||
gitRun (repo state) ["add", file]
|
|
||||||
gitRun (repo state) ["commit", "-m",
|
|
||||||
("git-annex annexed " ++ file), file]
|
|
||||||
logStatus state key ValuePresent
|
|
||||||
checkLegal file = do
|
checkLegal file = do
|
||||||
s <- getSymbolicLinkStatus file
|
s <- getSymbolicLinkStatus file
|
||||||
if ((isSymbolicLink s) || (not $ isRegularFile s))
|
if ((isSymbolicLink s) || (not $ isRegularFile s))
|
||||||
then error $ "not a regular file: " ++ file
|
then error $ "not a regular file: " ++ file
|
||||||
else return ()
|
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 ((linkTarget file) ++ reldest) file
|
||||||
|
gitRun (repo state) ["add", file]
|
||||||
|
gitRun (repo state) ["commit", "-m",
|
||||||
|
("git-annex annexed " ++ file), file]
|
||||||
|
logStatus state key ValuePresent
|
||||||
|
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. -}
|
{- Inverse of annexFile. -}
|
||||||
unannexFile :: State -> FilePath -> IO ()
|
unannexFile :: State -> FilePath -> IO ()
|
||||||
|
|
|
@ -40,7 +40,8 @@ annexLocation state backend key =
|
||||||
(gitWorkTree $ repo state) ++ "/" ++
|
(gitWorkTree $ repo state) ++ "/" ++
|
||||||
(annexLocationRelative state backend key)
|
(annexLocationRelative state backend key)
|
||||||
|
|
||||||
|
{- Annexed file's location relative to the gitWorkTree -}
|
||||||
annexLocationRelative :: State -> Backend -> Key -> FilePath
|
annexLocationRelative :: State -> Backend -> Key -> FilePath
|
||||||
annexLocationRelative state backend key =
|
annexLocationRelative state backend key =
|
||||||
gitDir (repo state) ++ "/annex/" ++ (name backend) ++
|
gitDir (repo state) ++ "/annex/" ++ (name backend) ++
|
||||||
"/" ++ (keyFile key)
|
"/" ++ (keyFile key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue