Fix repository already exists error code

oggit
Vadim vtroshchinskiy 2025-05-12 09:15:16 +02:00
parent 52fd7d8064
commit 990d11051e
1 changed files with 3 additions and 3 deletions

View File

@ -2367,7 +2367,7 @@ def git_create_repository():
Returns:
Response: A JSON response with a status message and HTTP status code.
- 200: If the repository already exists.
- 409: If the repository already exists.
- 201: If the repository is successfully created.
"""
data = request.json
@ -2381,7 +2381,7 @@ def git_create_repository():
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
if os.path.isdir(repo_path):
journal.send(f"Can't create repository {repo}, already exists at {repo_path}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"status": "Repository already exists"}), 200
return jsonify({"status": "Repository already exists"}), 409
module = _load_installer()
print(f"Got {module}")
@ -2531,7 +2531,7 @@ def git_create_branch(repo, branch):
Response: A JSON response containing a creation status
- 201: A JSON object with a "status" key containing "created"
- 404: A JSON object with an "error" key containing the message "Repository not found"
- 409: A JSON object with an "error" key containing the message "Tag already exists"
- 409: A JSON object with an "error" key containing the message "Branch already exists"
"""
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")