(self, package: Package)
Purge + download files returning files removed + added
Purge + download files returning files removed + added
Purge + download files returning files removed + added
async def sync_release_files(self, package: Package) -> None:
        """Purge + download files returning files removed + added"""
        downloaded_files = set()
        deferred_exception = None
        for release_file in package.release_files:
            release_path, download_urls = self.populate_download_urls(release_file)
            for cnt, url in enumerate(download_urls):
                try:
                    downloaded_file = await self.download_file(
                        url,
                        release_file["size"],
                        datetime.datetime.fromisoformat(
                            release_file["upload_time_iso_8601"].replace("Z", "+00:00")
                        ),
                        release_file["digests"]["sha256"],
                        urlpath=release_path,
                    )
                    if downloaded_file:
                        downloaded_files.add(
                            str(downloaded_file.relative_to(self.homedir))
                        )
                        break
                except Exception as e:
                    # Avoid flooding log messages with exception traceback
                    if not len(download_urls) == (cnt + 1):
                        logger.info(
                            "Continuing to next candidate URL after error downloading: "
                            f"{url}"
                        )
                    # Log an ERROR entry with traceback for the last URL entry in list,
                    # suggesting the final attemp of retriving the file has failed
                    else:
                        logger.exception(
                            "Continuing to next file after error downloading: " f"{url}"
                        )
                    # keep previous exception, also ignore non-default urls
                    if not deferred_exception and len(download_urls) == (cnt + 1):
                        deferred_exception = e
        if deferred_exception:
            raise deferred_exception  # raise the exception after trying all files

        self.altered_packages[package.name] = downloaded_files
async def sync_release_files ( self , package : Package ) -> None : downloaded_files = set ( ) deferred_exception = None for release_file in package . release_files : release_path , download_urls = self . populate_download_urls ( release_file ) for cnt , url in enumerate ( download_urls ) : try : downloaded_file = await self . download_file ( url , release_file [ "size" ] , datetime . datetime . fromisoformat ( release_file [ "upload_time_iso_8601" ] . replace ( "Z" , "+00:00" ) ) , release_file [ "digests" ] [ "sha256" ] , urlpath = release_path , ) if downloaded_file : downloaded_files . add ( str ( downloaded_file . relative_to ( self . homedir ) ) ) break except Exception as e : # Avoid flooding log messages with exception traceback if not len ( download_urls ) == ( cnt + 1 ) : logger . info ( "Continuing to next candidate URL after error downloading: " f"{url}" ) # Log an ERROR entry with traceback for the last URL entry in list, # suggesting the final attemp of retriving the file has failed else : logger . exception ( "Continuing to next file after error downloading: " f"{url}" ) # keep previous exception, also ignore non-default urls if not deferred_exception and len ( download_urls ) == ( cnt + 1 ) : deferred_exception = e if deferred_exception : raise deferred_exception # raise the exception after trying all files self . altered_packages [ package . name ] = downloaded_files