hookup annexgetfile
This commit is contained in:
parent
921313bcc7
commit
cad916d926
2 changed files with 14 additions and 7 deletions
19
Annex.hs
19
Annex.hs
|
@ -24,8 +24,8 @@ import LocationLog
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
{- An annexed file's content is stored somewhere under .git/annex/ -}
|
{- An annexed file's content is stored somewhere under .git/annex/ -}
|
||||||
annexDir :: GitRepo -> Key -> FilePath
|
annexLocation :: GitRepo -> Key -> FilePath
|
||||||
annexDir repo key = gitDir repo ++ "/annex/" ++ key
|
annexLocation repo key = gitDir repo ++ "/annex/" ++ key
|
||||||
|
|
||||||
{- On startup, examine the git repo, prepare it, and record state for
|
{- On startup, examine the git repo, prepare it, and record state for
|
||||||
- later. -}
|
- later. -}
|
||||||
|
@ -55,7 +55,7 @@ annexFile state file = do
|
||||||
Just key -> symlink key
|
Just key -> symlink key
|
||||||
where
|
where
|
||||||
symlink key = do
|
symlink key = do
|
||||||
let dest = annexDir (repo state) key
|
let dest = annexLocation (repo state) key
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
renameFile file dest
|
renameFile file dest
|
||||||
createSymbolicLink dest file
|
createSymbolicLink dest file
|
||||||
|
@ -77,7 +77,7 @@ unannexFile state file = do
|
||||||
case (mkey) of
|
case (mkey) of
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
Just key -> do
|
Just key -> do
|
||||||
let src = annexDir (repo state) key
|
let src = annexLocation (repo state) key
|
||||||
removeFile file
|
removeFile file
|
||||||
renameFile src file
|
renameFile src file
|
||||||
return ()
|
return ()
|
||||||
|
@ -88,9 +88,14 @@ annexGetFile state file = do
|
||||||
alreadyannexed <- lookupBackend state file
|
alreadyannexed <- lookupBackend state file
|
||||||
case (alreadyannexed) of
|
case (alreadyannexed) of
|
||||||
Nothing -> error $ "not annexed " ++ file
|
Nothing -> error $ "not annexed " ++ file
|
||||||
Just _ -> do error "not implemented" -- TODO
|
Just backend -> do
|
||||||
-- 1. find remote with file
|
key <- lookupKey state backend file
|
||||||
-- 2. copy file from remote
|
let dest = annexLocation (repo state) key
|
||||||
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
|
success <- retrieveFile state file dest
|
||||||
|
if (success)
|
||||||
|
then return ()
|
||||||
|
else error $ "failed to get " ++ file
|
||||||
|
|
||||||
{- Indicates a file is wanted. -}
|
{- Indicates a file is wanted. -}
|
||||||
annexWantFile :: State -> FilePath -> IO ()
|
annexWantFile :: State -> FilePath -> IO ()
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
module Backend (
|
module Backend (
|
||||||
lookupBackend,
|
lookupBackend,
|
||||||
storeFile,
|
storeFile,
|
||||||
|
retrieveFile,
|
||||||
|
lookupKey,
|
||||||
dropFile
|
dropFile
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue