Description
Description
Steps to reproduce:
- Create a repo from a template repo
- Create fails due to some reason (repo-avatar file not found, in my case)
- 500 error
- Go back in the browser to the new repository form
- Try to create an empty repo with the same name and owner (without the problematic template)
I expected the creation of an empty repo to work for a repo name that isn't used. However, the repo creation fails with an error message:
Files already exist for this repository. Contact the system administrator.
To fix it, the admin needs to delete the bare git repo from the filesystem using rm -r
. This makes the repo name available again.
In this case, one cause is the original file not found. However, filesystem changes like creating the bare git repo should get reverted in the case of an error, the same way that database changes are reverted using a transaction.
Here is the database transaction that reverts db changes. As far as I know, there is no equivalent clean-up for the filesystem.
gitea/services/repository/template.go
Line 74 in 0c72256
Contrast this with CreateRepositoryDirectly()
(not from a repo template), which cleans up.
gitea/services/repository/create.go
Lines 304 to 306 in 0c72256
However, it's unclear to me that the above code calling DeleteRepositoryDirectly()
(first introduced in #14384) actually cleans up the files because it first looks for the repo in the database, and if it's not there, returns early. At the point it's being called, the repo wouldn't be in the database because the transaction has been rolled back.
Gitea Version
1.20.5
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
Linux
How are you running Gitea?
docker
Database
PostgreSQL