From fb130bbf6fb6e225c657f3f91c47bda1228c3b8c Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Tue, 18 Oct 2022 14:29:54 +0200 Subject: [PATCH] Import packages links point to --- lib/importer.py | 15 ++++++++++++--- lib/obs_revision.py | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/importer.py b/lib/importer.py index 97c43d1..2c49369 100644 --- a/lib/importer.py +++ b/lib/importer.py @@ -127,15 +127,15 @@ class Importer: root = self.obs._history(project, package) if root is None: return - latest = DBRevision.latest_revision(db, project, self.package) + latest = DBRevision.latest_revision(db, project, package) for r in root.findall("revision"): - rev = OBSRevision(self.obs, self, project, self.package).parse(r) + rev = OBSRevision(self.obs, self, project, package).parse(r) if not latest or rev.rev > latest.rev: dbrev = DBRevision.import_obs_rev(db, rev) root = rev.read_link() if root: tprj = root.get("project") or project - tpkg = root.get("package") or self.package + tpkg = root.get("package") or package dbrev.links_to(db, tprj, tpkg) db.conn.commit() @@ -144,6 +144,15 @@ class Importer: for project, _, api_url in self.projects: self.obs.change_url(api_url) self.update_db_package(db, project, self.package) + cur = db.cursor() + cur.execute( + "SELECT DISTINCT l.project, l.package from links l join revisions r on r.id=l.revision_id WHERE r.project=%s AND r.package=%s", + (project, self.package), + ) + for row in cur.fetchall(): + (lproject, lpackage) = row + self.update_db_package(db, lproject, lpackage) + cur.close() def import_all_revisions(self, gc): # Fetch all the requests and sort them. Ideally we should diff --git a/lib/obs_revision.py b/lib/obs_revision.py index 0cc6799..0143c2c 100644 --- a/lib/obs_revision.py +++ b/lib/obs_revision.py @@ -64,7 +64,8 @@ class OBSRevision: def read_link(self): try: return self.obs._xml( - f"source/{self.project}/{self.package}/_link", rev=self.srcmd5 + f"source/{self.project}/{self.package}/_link", + rev=self.unexpanded_srcmd5, ) except HTTPError as e: if e.code == 404: @@ -81,7 +82,7 @@ class OBSRevision: target_project = root.get("project") except ET.ParseError: logging.error( - f"_link can't be parsed [{self.project}/{self.package} rev={self.srcmd5}]" + f"_link can't be parsed [{self.project}/{self.package} rev={self.unexpanded_srcmd5}]" ) return False