From f6445819532e9751fec3633c1fa642c2ac9e27ae Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:32:01 +0200 Subject: [PATCH] Improve SHA256 checksum parsing for Deno Enhances the verify_deno_sha256 function to support both standard Unix and verbose checksum file formats. Adds debug logging for cases where the hash cannot be found. --- src/core/ytsage_deno.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/ytsage_deno.py b/src/core/ytsage_deno.py index 7444cfd..2c4304f 100644 --- a/src/core/ytsage_deno.py +++ b/src/core/ytsage_deno.py @@ -52,14 +52,26 @@ def verify_deno_sha256(file_path: Path, sha256_url: str) -> bool: response.raise_for_status() checksum_content = response.text - # Parse the checksum file - format is: - # Algorithm : SHA256 - # Hash : - # Path : + # Parse the checksum file + # Format can be either: + # 1. Standard Unix format: "hash filename" + # 2. Verbose format: "Hash : " expected_hash = None for line in checksum_content.strip().split("\n"): + line = line.strip() + if not line: + continue + + # Try standard Unix format first (hash followed by spaces and filename) + if len(line) >= 64 and (" " in line or "\t" in line): + # Extract first 64 characters as potential hash + potential_hash = line.split()[0] + if len(potential_hash) == 64 and all(c in "0123456789abcdefABCDEF" for c in potential_hash): + expected_hash = potential_hash + break + + # Try verbose format if line.startswith("Hash"): - # Extract hash from "Hash : " format parts = line.split(":", 1) if len(parts) == 2: expected_hash = parts[1].strip() @@ -67,6 +79,7 @@ def verify_deno_sha256(file_path: Path, sha256_url: str) -> bool: if not expected_hash: logger.error("Could not find SHA256 hash in checksum file") + logger.debug(f"Checksum file content: {checksum_content}") return False # Calculate actual hash of downloaded file