diff --git a/Assistant/WebApp/RepoList.hs b/Assistant/WebApp/RepoList.hs index fa24055a1d..23b74a2b55 100644 --- a/Assistant/WebApp/RepoList.hs +++ b/Assistant/WebApp/RepoList.hs @@ -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)] diff --git a/Config/Cost.hs b/Config/Cost.hs index 94bab1fe1c..dc391a5a57 100644 --- a/Config/Cost.hs +++ b/Config/Cost.hs @@ -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]