Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API PATCH ​/repos​/{owner}​/{repo} changes repo units (wiki, tracker) even if not set #7758

Closed
2 of 7 tasks
davidsvantesson opened this issue Aug 5, 2019 · 3 comments
Labels
Milestone

Comments

@davidsvantesson
Copy link
Contributor

davidsvantesson commented Aug 5, 2019

  • Gitea version (or commit ref): 1.10.0+dev-136-g52feff5a5
  • Git version: Not relevant
  • Operating system: Ubuntu
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

API: PATCH "​/repos​/{owner}​/{repo}" has the following description:
"Edit a repository's properties. Only fields that are set will be changed."
When executing the API without for example "has_wiki" in the body, the wiki is disabled. Similar for other repo units.

I think this is because function UpdateRepositoryUnits in models/repo.go delete all repo_units for the specified repo_id and then inserts the set repo units again. While the function updateRepoUnits in api/v1/repo/repo.go only adds those repo_units it wants to change.
I am not sure if the change should be in the model or in the api function.

@davidsvantesson
Copy link
Contributor Author

Does xorm support "ON DUPLICATE KEY"? It could be used to solve this issue, instead of deleting everything and inserting, just insert or update if not existing.

@lunny lunny added the type/bug label Aug 5, 2019
@lunny
Copy link
Member

lunny commented Aug 5, 2019

@davidsvantesson xorm doesn't support that.

@davidsvantesson
Copy link
Contributor Author

Current logic seem to be that all repo_units written at each change, since settings page write everything each time, and also Issues/ExternalTracker and Wiki/ExternalWiki is mutually exclusive so they must be deleted when updated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants