diff --git a/README.rst b/README.rst index da4e2f25..96ebb84d 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,7 @@ Possible response codes are for various requests include: - HTTP 403 Forbidden - The SCM URL is not pointing to a whitelisted SCM server. - HTTP 404 Not Found - The requested URL has no handler associated with it or the requested resource doesn't exist. +- HTTP 409 Conflict - The submitted module's NVR already exists. - HTTP 422 Unprocessable Entity - The submitted modulemd file is not valid or the module components cannot be retrieved - HTTP 500 Internal Server Error - An unknown error occured. diff --git a/rida.py b/rida.py index 26419bc4..588bed2e 100755 --- a/rida.py +++ b/rida.py @@ -99,6 +99,9 @@ def submit_build(): mmd.loads(yaml) except: return "Invalid modulemd", 422 + if db.session.query(rida.database.Module).filter_by(name=mmd.name, + version=mmd.version, release=mmd.release).first(): + return "Module already exists", 409 module = rida.database.Module(name=mmd.name, version=mmd.version, release=mmd.release, state="init", modulemd=yaml) db.session.add(module)