From e6d2323d63376a9bcc4066c5c06873fd68e77343 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Fri, 24 Jan 2025 22:23:28 -0800 Subject: [PATCH] umu_bspatch: raise exception on verify failure --- umu/umu_bspatch.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/umu/umu_bspatch.py b/umu/umu_bspatch.py index 6f062217f..13fe60f53 100644 --- a/umu/umu_bspatch.py +++ b/umu/umu_bspatch.py @@ -217,9 +217,7 @@ def result(self) -> list[Future]: """Return the currently submitted tasks.""" return self._futures - def _check_binaries( - self, proton: Path, item: ManifestEntry - ) -> ManifestEntry | None: + def _check_binaries(self, proton: Path, item: ManifestEntry) -> ManifestEntry: rpath: Path = proton.joinpath(item["name"]) try: @@ -227,15 +225,11 @@ def _check_binaries( stats: os.stat_result = os.fstat(fp.fileno()) xxhash: int = 0 if item["size"] != stats.st_size: - log.error( - "Expected size %s, received %s", item["size"], stats.st_size - ) - return None + err: str = f"Expected size {item['size']}, received {stats.st_size}" + raise ValueError(err) if item["mode"] != stats.st_mode: - log.error( - "Expected mode %s, received %s", item["mode"], stats.st_mode - ) - return None + err: str = f"Expected mode {item['mode']}, received {stats.st_mode}" + raise ValueError(err) if stats.st_size > MMAP_MIN: with mmap(fp.fileno(), length=0, access=ACCESS_READ) as mm: # Ignore. Passing an mmap is valid here @@ -245,11 +239,11 @@ def _check_binaries( else: xxhash = xxh3_64_intdigest(fp.read()) if item["xxhash"] != xxhash: - log.error("Expected xxhash %s, received %s", item["xxhash"], xxhash) - return None + err: str = f"Expected xxhash {item['xxhash']}, received {xxhash}" + raise ValueError(err) except FileNotFoundError: log.debug("Aborting partial update, file not found: %s", rpath) - return None + raise return item