make higher priorities and full scans be preserved when adding

This commit is contained in:
Joey Hess 2012-08-24 13:28:20 -04:00
parent 72e110ce5d
commit 9fafddc7eb

View file

@ -45,6 +45,10 @@ addScanRemotes :: ScanRemoteMap -> [Remote] -> Bool -> IO ()
addScanRemotes _ [] _ = noop
addScanRemotes v rs full = atomically $ do
m <- fromMaybe M.empty <$> tryTakeTMVar v
putTMVar v $ M.union (M.fromList $ zip rs (map info rs)) m
putTMVar v $ M.unionWith merge (M.fromList $ zip rs (map info rs)) m
where
info r = ScanInfo (Remote.cost r) full
merge x y = ScanInfo
{ scanPriority = max (scanPriority x) (scanPriority y)
, fullScan = fullScan x || fullScan y
}