it works!!

This commit is contained in:
Joey Hess 2010-10-13 16:32:16 -04:00
parent f87c5ed949
commit e5c1db355f

View file

@ -48,30 +48,31 @@ copyKeyFile state key file = do
"To get that file, need access to one of these remotes: " ++ "To get that file, need access to one of these remotes: " ++
(remotesList full) (remotesList full)
trycopy full (r:rs) = do trycopy full (r:rs) = do
putStrLn "trying a remote"
result <- try (copyFromRemote r key file)::IO (Either SomeException ()) result <- try (copyFromRemote r key file)::IO (Either SomeException ())
case (result) of case (result) of
Left err -> do Left err -> do
showerr err r hPutStrLn stderr (show err)
trycopy full rs trycopy full rs
Right succ -> return True Right succ -> return True
showerr err r = do
hPutStrLn stderr $ "git-annex: copy from " ++
(gitRepoDescribe r ) ++ " failed: " ++
(show err)
{- Tries to copy a file from a remote, exception on error. -} {- Tries to copy a file from a remote, exception on error. -}
copyFromRemote :: GitRepo -> Key -> FilePath -> IO () copyFromRemote :: GitRepo -> Key -> FilePath -> IO ()
copyFromRemote r key file = do copyFromRemote r key file = do
r <- if (gitRepoIsLocal r) putStrLn $ "copy from " ++ (gitRepoDescribe r ) ++ " " ++ file
then getlocal
else getremote -- annexLocation needs the git config read for the remote first.
-- FIXME: Having this here means git-config is run repeatedly when
-- copying a series of files; need to use state monad to avoid
-- this.
r' <- gitConfigRead r
_ <- if (gitRepoIsLocal r')
then getlocal r'
else getremote r'
return () return ()
where where
getlocal = do getlocal r = do
putStrLn $ "get: " ++ location rawSystem "cp" ["-a", location r, file]
rawSystem "cp" ["-a", location, file] getremote r = do
getremote = do
putStrLn $ "get: " ++ location
error "get via network not yet implemented!" error "get via network not yet implemented!"
location = annexLocation r backend key location r = annexLocation r backend key