gitea.lister: Fix uid to be unique across instance
The gitea lister can be run on multiple instances which could use the same id. So listing another gitea instance, the current code would fail to insert data for such case. This commit fixes that behavior by prefixing the uid with the instance name. Related to T2577
This commit is contained in:
parent
e3c856b5ee
commit
31efda62e7
2 changed files with 3 additions and 6 deletions
|
@ -35,7 +35,7 @@ class GiteaLister(PageByPageHttpLister):
|
|||
def get_model_from_repo(self, repo: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return {
|
||||
"instance": self.instance,
|
||||
"uid": repo["id"],
|
||||
"uid": f'{self.instance}/{repo["id"]}',
|
||||
"name": repo["name"],
|
||||
"full_name": repo["full_name"],
|
||||
"html_url": repo["html_url"],
|
||||
|
@ -43,9 +43,6 @@ class GiteaLister(PageByPageHttpLister):
|
|||
"origin_type": "git",
|
||||
}
|
||||
|
||||
def uid(self, id: str) -> str:
|
||||
return f"{self.instance}/{id}"
|
||||
|
||||
def get_next_target_from_response(self, response: Response) -> Optional[int]:
|
||||
"""Determine the next page identifier.
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# License: GNU General Public License version 3, or any later version
|
||||
# See top-level LICENSE file for more information
|
||||
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy import Column, String
|
||||
|
||||
from ..core.models import ModelBase
|
||||
|
||||
|
@ -14,5 +14,5 @@ class GiteaModel(ModelBase):
|
|||
|
||||
__tablename__ = "gitea_repo"
|
||||
|
||||
uid = Column(Integer, primary_key=True)
|
||||
uid = Column(String, primary_key=True)
|
||||
instance = Column(String, index=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue