aboutsummaryrefslogtreecommitdiff
path: root/Config.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-13 14:10:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-13 14:10:29 -0400
commit9a378b18fb1fe1b87bc9182e964eddabb6779b86 (patch)
tree2ec20d46fc60939657725b5e8b7375b1a65f6365 /Config.hs
parent27869d94dfb18784bbd53c4191c2000ee37ff30c (diff)
webapp: Set locally paired repositories to a lower cost than other network remotes.
Diffstat (limited to 'Config.hs')
-rw-r--r--Config.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Config.hs b/Config.hs
index 2eaf17bf8..b732f982f 100644
--- a/Config.hs
+++ b/Config.hs
@@ -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
]