From c40582183e7315af7e4432a4e2c779097794a9ea Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 13 Nov 2024 14:22:08 +0000 Subject: [PATCH] ota_core: fix not reporting dynamic parsed information --- src/otaclient/ota_core.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/otaclient/ota_core.py b/src/otaclient/ota_core.py index 9ae6e36e0..af8d22138 100644 --- a/src/otaclient/ota_core.py +++ b/src/otaclient/ota_core.py @@ -241,13 +241,6 @@ def __init__( _path = f"{_url_base.path.rstrip('/')}/" self.url_base = _url_base._replace(path=_path).geturl() - # ------ information from OTA image meta and delta generation ------ # - self.total_files_size_uncompressed = 0 - self.total_files_num = 0 - self.total_download_files_num = 0 - self.total_download_fiies_size = 0 - self.total_remove_files_num = 0 - # ------ setup downloader ------ # self._downloader_pool = DownloaderPool( instance_num=cfg.DOWNLOAD_THREADS, @@ -264,10 +257,18 @@ def _calculate_delta( ) -> DeltaBundle: logger.info("start to calculate and prepare delta...") delta_bundle = standby_slot_creator.calculate_and_prepare_delta() + # update dynamic information - self.total_download_files_num = len(delta_bundle.download_list) - self.total_download_fiies_size = delta_bundle.total_download_files_size - self.total_remove_files_num = len(delta_bundle.rm_delta) + self._status_report_queue.put_nowait( + StatusReport( + payload=SetUpdateMetaReport( + total_download_files_num=len(delta_bundle.download_list), + total_download_files_size=delta_bundle.total_download_files_size, + total_remove_files_num=len(delta_bundle.rm_delta), + ), + session_id=self.session_id, + ) + ) return delta_bundle def _download_files( @@ -439,8 +440,16 @@ def _execute_update(self): run_dir=Path(cfg.RUN_DIR), ca_chains_store=self.ca_chains_store, ) - self.total_files_num = otameta.total_files_num - self.total_files_size_uncompressed = otameta.total_files_size_uncompressed + self._status_report_queue.put_nowait( + StatusReport( + payload=SetUpdateMetaReport( + image_file_entries=otameta.total_files_num, + image_size_uncompressed=otameta.total_files_size_uncompressed, + metadata_downloaded_bytes=self._downloader_pool.total_downloaded_bytes, + ), + session_id=self.session_id, + ) + ) except ota_metadata_parser.MetadataJWTVerificationFailed as e: _err_msg = f"failed to verify metadata.jwt: {e!r}" logger.error(_err_msg)