(self)
Update the self.packages_to_sync to contain packages that need to be
        synced.
Update the self.packages_to_sync to contain packages that need to be
        synced.
Update the self . packages_to_sync to contain packages that need to be synced .
async def determine_packages_to_sync(self) -> None:
        """
        Update the self.packages_to_sync to contain packages that need to be
        synced.
        """
        # In case we don't find any changes we will stay on the currently
        # synced serial.
        self.target_serial = self.synced_serial
        self.packages_to_sync = {}
        logger.info(f"Current mirror serial: {self.synced_serial}")
        self.need_wrapup = True

        if self.storage_backend.exists(self.todolist):
            # We started a sync previously and left a todo list as well as the
            # targetted serial. We'll try to keep going through the todo list
            # and then mark the targetted serial as done
            logger.info("Resuming interrupted sync from local todo list.")
            with self.storage_backend.open_file(self.todolist, text=True) as fh:
                saved_todo = iter(fh)
                self.target_serial = int(next(saved_todo).strip())
                for line in saved_todo:
                    package, serial = line.strip().split()
                    self.packages_to_sync[package] = int(serial)
        elif not self.synced_serial:
            logger.info("Syncing all packages.")
            # First get the current serial, then start to sync. This makes us
            # more defensive in case something changes on the server between
            # those two calls.
            all_packages = await self.master.all_packages()
            self.packages_to_sync.update(all_packages)
            self.target_serial = self.find_target_serial()
        else:
            logger.info("Syncing based on changelog.")
            changed_packages = await self.master.changed_packages(self.synced_serial)
            self.packages_to_sync.update(changed_packages)
            self.target_serial = self.find_target_serial()
            # We can avoid writing the main index page if we don't have
            # anything todo at all during a changelog-based sync.
            self.need_index_sync = bool(self.packages_to_sync)

        self._filter_packages()
        logger.info(f"Trying to reach serial: {self.target_serial}")
        pkg_count = len(self.packages_to_sync)
        logger.info(f"{pkg_count} packages to sync.")
async def determine_packages_to_sync ( self ) -> None : # In case we don't find any changes we will stay on the currently # synced serial. self . target_serial = self . synced_serial self . packages_to_sync = { } logger . info ( f"Current mirror serial: {self.synced_serial}" ) self . need_wrapup = True if self . storage_backend . exists ( self . todolist ) : # We started a sync previously and left a todo list as well as the # targetted serial. We'll try to keep going through the todo list # and then mark the targetted serial as done logger . info ( "Resuming interrupted sync from local todo list." ) with self . storage_backend . open_file ( self . todolist , text = True ) as fh : saved_todo = iter ( fh ) self . target_serial = int ( next ( saved_todo ) . strip ( ) ) for line in saved_todo : package , serial = line . strip ( ) . split ( ) self . packages_to_sync [ package ] = int ( serial ) elif not self . synced_serial : logger . info ( "Syncing all packages." ) # First get the current serial, then start to sync. This makes us # more defensive in case something changes on the server between # those two calls. all_packages = await self . master . all_packages ( ) self . packages_to_sync . update ( all_packages ) self . target_serial = self . find_target_serial ( ) else : logger . info ( "Syncing based on changelog." ) changed_packages = await self . master . changed_packages ( self . synced_serial ) self . packages_to_sync . update ( changed_packages ) self . target_serial = self . find_target_serial ( ) # We can avoid writing the main index page if we don't have # anything todo at all during a changelog-based sync. self . need_index_sync = bool ( self . packages_to_sync ) self . _filter_packages ( ) logger . info ( f"Trying to reach serial: {self.target_serial}" ) pkg_count = len ( self . packages_to_sync ) logger . info ( f"{pkg_count} packages to sync." )