diff --git a/swh/loader/package/debian/loader.py b/swh/loader/package/debian/loader.py --- a/swh/loader/package/debian/loader.py +++ b/swh/loader/package/debian/loader.py @@ -89,27 +89,32 @@ yield release_name(version), p_info def resolve_revision_from( - self, known_package_artifacts: Dict, artifact_metadata: Dict) \ + self, known_package_artifacts: Mapping, + artifact_metadata: Mapping[str, Any]) \ -> Optional[bytes]: - artifacts_to_fetch = artifact_metadata['files'] + artifacts_to_fetch = artifact_metadata.get('files') + # No files in the artifact, no revision resolution possible + if not artifacts_to_fetch: + return None logger.debug('k_p_artifacts: %s', known_package_artifacts) logger.debug('artifacts_to_fetch: %s', artifacts_to_fetch) for rev_id, known_artifacts in known_package_artifacts.items(): logger.debug('Revision: %s', rev_id) logger.debug('Associated known_artifacts: %s', known_artifacts) known_artifacts = known_artifacts['extrinsic']['raw']['files'] - rev_found = True + rev_found = False for a_name, k_artifact in known_artifacts.items(): artifact_to_fetch = artifacts_to_fetch.get(a_name) logger.debug('artifact_to_fetch: %s', artifact_to_fetch) if artifact_to_fetch is None: # as soon as we do not see an artifact, we consider we need # to check the other revision - rev_found = False - if k_artifact['sha256'] != artifact_to_fetch['sha256']: + continue + if k_artifact['sha256'] == artifact_to_fetch['sha256']: # Hash is different, we consider we need to check the other # revisions - rev_found = False + rev_found = True + break if rev_found: logger.debug('Existing revision %s found for new artifacts.', rev_id)