change insert to do nothing on conflict

This commit is contained in:
Lucy Cifferello
2024-07-11 16:39:09 -04:00
parent 4c42c177e8
commit cdd3950167

View File

@@ -99,7 +99,7 @@ import Network.HTTP.Types.Status (status401)
import Yesod (getsYesod) import Yesod (getsYesod)
import Settings (AppSettings(whitelist)) import Settings (AppSettings(whitelist))
import Network.HTTP.Types (status200) import Network.HTTP.Types (status200)
import Database.Persist (insert_) import Database.Persist (insert_, insertBy)
import Yesod (lookupPostParam) import Yesod (lookupPostParam)
import Data.Maybe (isNothing) import Data.Maybe (isNothing)
@@ -307,7 +307,7 @@ checkAdminAuthUpload pkgId = do
else if authorized && newPkg else if authorized && newPkg
-- if pkg is whitelisted and a new upload, add as authorized for this admin user -- if pkg is whitelisted and a new upload, add as authorized for this admin user
then do then do
runDB $ insert_ (AdminPkgs (AdminKey name) pkgId) _ <- runDB $ insertBy (AdminPkgs (AdminKey name) pkgId)
pure name pure name
else sendResponseText status401 "User not authorized to upload this package." else sendResponseText status401 "User not authorized to upload this package."
else sendResponseText status401 "Package does not belong on this registry." else sendResponseText status401 "Package does not belong on this registry."