From 72ddf3b134a21896f40c94e8a9c7173f4274b7fe Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Mon, 2 Jan 2017 11:32:40 +0100 Subject: reporead: Check if package exists in other repo before adopting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auto-adoption should only happen on new packages, so rebuilds of orphaned packages pushed to staging shouldn't cause them to be adopted. Signed-off-by: Johannes Löthberg --- devel/management/commands/reporead.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index 08853a32..70526bfd 100644 --- a/devel/management/commands/reporead.py +++ b/devel/management/commands/reporead.py @@ -398,16 +398,18 @@ def db_update(archname, reponame, pkgs, force=False): populate_pkg(dbpkg, pkg, timestamp=timestamp) Update.objects.log_update(None, dbpkg) - maintainers = User.objects.filter( - package_relations__pkgbase=dbpkg.pkgbase, - package_relations__type=PackageRelation.MAINTAINER) - if not maintainers: - packager = finder.find(pkg.packager) - if packager: - prel = PackageRelation(pkgbase=dbpkg.pkgbase, - user=packager, - type=PackageRelation.MAINTAINER) - prel.save() + if not Package.objects.filter( + pkgname=pkg.name).exclude(id=dbpkg.id).exists(): + if not User.objects.filter( + package_relations__pkgbase=dbpkg.pkgbase, + package_relations__type=PackageRelation.MAINTAINER + ).exists(): + packager = finder.find(pkg.packager) + if packager: + prel = PackageRelation(pkgbase=dbpkg.pkgbase, + user=packager, + type=PackageRelation.MAINTAINER) + prel.save() except IntegrityError: -- cgit v1.2.3-54-g00ecf