minor robustness fixes in repo cost reordering code
This commit is contained in:
parent
705cb5a84a
commit
69cc8e83ce
2 changed files with 7 additions and 7 deletions
|
@ -187,16 +187,16 @@ getRepositoriesReorderR = do
|
|||
{- Get uuid of the moved item, and the list it was moved within. -}
|
||||
moved <- fromjs <$> runInputGet (ireq textField "moved")
|
||||
list <- map fromjs <$> lookupGetParams "list[]"
|
||||
void $ liftAnnex $ do
|
||||
remote <- fromMaybe (error "Unknown UUID") <$>
|
||||
Remote.remoteFromUUID moved
|
||||
liftAnnex $ go list =<< Remote.remoteFromUUID moved
|
||||
liftAssistant updateSyncRemotes
|
||||
where
|
||||
go _ Nothing = noop
|
||||
go list (Just remote) = do
|
||||
rs <- catMaybes <$> mapM Remote.remoteFromUUID list
|
||||
forM_ (reorderCosts remote rs) $ \(r, newcost) ->
|
||||
when (Remote.cost r /= newcost) $
|
||||
setRemoteCost r newcost
|
||||
remoteListRefresh
|
||||
liftAssistant updateSyncRemotes
|
||||
where
|
||||
void remoteListRefresh
|
||||
fromjs = toUUID . T.unpack
|
||||
|
||||
reorderCosts :: Remote -> [Remote] -> [(Remote, Cost)]
|
||||
|
|
|
@ -42,7 +42,7 @@ encryptedRemoteCostAdj = 50
|
|||
- position longer than the list.
|
||||
-}
|
||||
insertCostAfter :: [Cost] -> Int -> [Cost]
|
||||
insertCostAfter [] _ = error "insertCostAfter: empty list"
|
||||
insertCostAfter [] _ = []
|
||||
insertCostAfter l pos
|
||||
| pos < 0 = costBetween 0 (l !! 0) : l
|
||||
| nextpos > maxpos = l ++ [1 + l !! maxpos]
|
||||
|
|
Loading…
Reference in a new issue