support using scp for ssh remotes

This commit is contained in:
Joey Hess 2010-10-22 13:21:43 -04:00
parent 8da596feff
commit 9f13f3ac5e

View file

@ -81,11 +81,15 @@ copyFromRemote :: Git.Repo -> Key -> FilePath -> IO Bool
copyFromRemote r key file = do copyFromRemote r key file = do
if (Git.repoIsLocal r) if (Git.repoIsLocal r)
then getlocal then getlocal
else getremote else if (Git.repoIsSsh r)
then getssh
else error "copying from non-ssh repo not supported"
where where
getlocal = boolSystem "cp" ["-a", location, file]
getremote = return False -- TODO implement get from remote
location = annexLocation r key location = annexLocation r key
getlocal = boolSystem "cp" ["-a", location, file]
getssh = do
liftIO $ putStrLn "" -- make way for scp progress bar
boolSystem "scp" [location, file]
showLocations :: Key -> Annex () showLocations :: Key -> Annex ()
showLocations key = do showLocations key = do
@ -130,10 +134,10 @@ checkRemoveKey key = do
Right True -> findcopies need (have+1) rs bad Right True -> findcopies need (have+1) rs bad
Right False -> findcopies need have rs bad Right False -> findcopies need have rs bad
Left _ -> findcopies need have rs (r:bad) Left _ -> findcopies need have rs (r:bad)
remoteHasKey r all = do remoteHasKey remote all = do
-- To check if a remote has a key, construct a new -- To check if a remote has a key, construct a new
-- Annex monad and query its backend. -- Annex monad and query its backend.
a <- Annex.new r all a <- Annex.new remote all
(result, _) <- Annex.run a (Backend.hasKey key) (result, _) <- Annex.run a (Backend.hasKey key)
return result return result
notEnoughCopies need have bad = do notEnoughCopies need have bad = do