Skip to content

Commit

Permalink
synchrotron: Print better debug info if adopted binaries were found i…
Browse files Browse the repository at this point in the history
…n target
  • Loading branch information
ximion committed Oct 10, 2023
1 parent 52c4802 commit 4671d87
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/synchrotron/syncengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,13 @@ def _sync_packages_internal(self, session, component_name: str, pkgnames: list[s
continue

# test if binaries of the to-be-synced package are taken over in target
if self._has_binaries_adopted_in_target(session, orig_bpkg_arch_map, rss, spkg):
has_adopted_bins, adopted_example = self._check_binaries_adopted_in_target(
session, orig_bpkg_arch_map, rss, spkg
)
if has_adopted_bins:
log.debug(
'Not syncing {}/{}: Destination has newer, possibly adopted binaries.'.format(
spkg.name,
spkg.version,
'Not syncing {}/{}: Destination has newer, possibly adopted binaries (found %s/%s).'.format(
spkg.name, spkg.version, adopted_example.name, adopted_example.version
)
)
continue
Expand Down Expand Up @@ -733,7 +735,7 @@ def _is_candidate(self, spkg: ExternalSourcePackage, dpkg: SourcePackage):
return False
return True

def _has_binaries_adopted_in_target(
def _check_binaries_adopted_in_target(
self,
session,
orig_bpkg_arch_map: dict[str, dict[str, ExternalBinaryPackage]],
Expand All @@ -752,20 +754,19 @@ def _has_binaries_adopted_in_target(
break
if not bin:
bin = ebin
newer_bin_exists = (
session.query(BinaryPackage.uuid)
newer_bin = (
session.query(BinaryPackage)
.filter(
BinaryPackage.name == bin.name,
BinaryPackage.version > bin.version,
BinaryPackage.repo_id == rss.repo_id,
BinaryPackage.suites.any(id=rss.suite_id),
)
.first()
is not None
)
if newer_bin_exists:
return True
return False
if newer_bin is not None:
return True, newer_bin
return False, None

def _autosync_internal(self, session, remove_cruft: bool = True) -> bool:
"""Synchronize all packages between source and destination."""
Expand Down Expand Up @@ -937,11 +938,13 @@ def _autosync_internal(self, session, remove_cruft: bool = True) -> bool:
continue

# test if binaries of the to-be-synced package are taken over in target
if self._has_binaries_adopted_in_target(session, orig_bpkg_arch_map, rss, spkg):
has_adopted_bins, adopted_example = self._check_binaries_adopted_in_target(
session, orig_bpkg_arch_map, rss, spkg
)
if has_adopted_bins:
log.debug(
'Not syncing {}/{}: Destination has newer, possibly adopted binaries.'.format(
spkg.name,
spkg.version,
'Not syncing {}/{}: Destination has newer, possibly adopted binaries (found: %s/%s).'.format(
spkg.name, spkg.version, adopted_example.name, adopted_example.version
)
)
continue
Expand Down

0 comments on commit 4671d87

Please sign in to comment.