diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-13 14:10:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-13 14:10:29 -0400 |
commit | 9a378b18fb1fe1b87bc9182e964eddabb6779b86 (patch) | |
tree | 2ec20d46fc60939657725b5e8b7375b1a65f6365 /Config.hs | |
parent | 27869d94dfb18784bbd53c4191c2000ee37ff30c (diff) |
webapp: Set locally paired repositories to a lower cost than other network remotes.
Diffstat (limited to 'Config.hs')
-rw-r--r-- | Config.hs | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -12,6 +12,7 @@ import qualified Git import qualified Git.Config import qualified Git.Command import qualified Annex +import qualified Types.Remote as Remote type UnqualifiedConfigKey = String data ConfigKey = ConfigKey String @@ -50,10 +51,15 @@ remoteCost c def = case remoteAnnexCostCommand c of readProcess "sh" ["-c", cmd] _ -> return $ fromMaybe def $ remoteAnnexCost c +setRemoteCost :: Remote -> Int -> Annex () +setRemoteCost r c = setConfig (remoteConfig (Remote.repo r) "cost") (show c) + cheapRemoteCost :: Int cheapRemoteCost = 100 semiCheapRemoteCost :: Int semiCheapRemoteCost = 110 +semiExpensiveRemoteCost :: Int +semiExpensiveRemoteCost = 175 expensiveRemoteCost :: Int expensiveRemoteCost = 200 veryExpensiveRemoteCost :: Int @@ -68,9 +74,10 @@ prop_cost_sane :: Bool prop_cost_sane = False `notElem` [ expensiveRemoteCost > 0 , cheapRemoteCost < semiCheapRemoteCost - , semiCheapRemoteCost < expensiveRemoteCost + , semiCheapRemoteCost < semiExpensiveRemoteCost + , semiExpensiveRemoteCost < expensiveRemoteCost , cheapRemoteCost + encryptedRemoteCostAdj > semiCheapRemoteCost - , cheapRemoteCost + encryptedRemoteCostAdj < expensiveRemoteCost + , cheapRemoteCost + encryptedRemoteCostAdj < semiExpensiveRemoteCost , semiCheapRemoteCost + encryptedRemoteCostAdj < expensiveRemoteCost ] |