webapp: Set locally paired repositories to a lower cost than other network remotes.

This commit is contained in:
Joey Hess 2013-03-13 14:10:29 -04:00
parent 02facde154
commit 9b657a2ccc
7 changed files with 28 additions and 8 deletions

View file

@ -20,15 +20,17 @@ import qualified Command.InitRemote
import Logs.UUID
import Logs.Remote
import Git.Remote
import Config
import qualified Data.Text as T
import qualified Data.Map as M
{- Sets up and begins syncing with a new ssh or rsync remote. -}
makeSshRemote :: Bool -> SshData -> Assistant Remote
makeSshRemote forcersync sshdata = do
makeSshRemote :: Bool -> SshData -> Maybe Int -> Assistant Remote
makeSshRemote forcersync sshdata mcost = do
r <- liftAnnex $
addRemote $ maker (sshRepoName sshdata) sshurl
liftAnnex $ maybe noop (setRemoteCost r) mcost
syncNewRemote r
return r
where

View file

@ -12,6 +12,7 @@ import Assistant.Ssh
import Assistant.Pairing
import Assistant.Pairing.Network
import Assistant.MakeRemote
import Config
import Network.Socket
import qualified Data.Text as T
@ -42,7 +43,7 @@ finishedLocalPairing msg keypair = do
, "git-annex-shell -c configlist " ++ T.unpack (sshDirectory sshdata)
]
Nothing
void $ makeSshRemote False sshdata
void $ makeSshRemote False sshdata (Just semiExpensiveRemoteCost)
{- Mostly a straightforward conversion. Except:
- * Determine the best hostname to use to contact the host.

View file

@ -279,7 +279,7 @@ makeSsh' rsync setup sshdata keypair =
makeSshRepo :: Bool -> (Remote -> Handler ()) -> SshData -> Handler RepHtml
makeSshRepo forcersync setup sshdata = do
r <- liftAssistant $ makeSshRemote forcersync sshdata
r <- liftAssistant $ makeSshRemote forcersync sshdata Nothing
setup r
redirect $ EditNewCloudRepositoryR $ Remote.uuid r