From 7ebead0b535ff700930155232f1fea89a93f799f Mon Sep 17 00:00:00 2001 From: Lucas Vivo Date: Mon, 16 Nov 2026 19:41:36 +0100 Subject: [PATCH] feat(wallpaper_changer): decode_all should decode lonley jpg_enc with default name --- .../src/wallpaper_changer/image_repository.py | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/wallpaper_changer/src/wallpaper_changer/image_repository.py b/wallpaper_changer/src/wallpaper_changer/image_repository.py index 0274194..9757470 100644 --- a/wallpaper_changer/src/wallpaper_changer/image_repository.py +++ b/wallpaper_changer/src/wallpaper_changer/image_repository.py @@ -245,24 +245,20 @@ class ImageRepository: raise FileNotFoundError("No naming table found") decoded_paths = [] sources_to_remove = [] - for encrypted_path in encrypted_images: if self._is_jpg(encrypted_path): continue - - image_name,image_hash = next( - (item.image_name,item.image_hash) - for item in naming_table - if item.encrypted_file == encrypted_path.name - ) - if image_name is None: - image_name = self._find_name_in_legacy_tables(encrypted_path.name) - logger.warning( - f"Could not find original name for {encrypted_path.name} in naming table, " - f"checking legacy tables: {image_name}" + try: + image_name, image_hash = next( + (item.image_name, item.image_hash) + for item in naming_table + if item.encrypted_file == encrypted_path.name ) + except StopIteration: + image_name = None + image_hash = None if image_name is None: - image_name = f"Sexy_MISSING_{len(decoded_paths) + 1}.jpg" + image_name = self._unique_identifier("MissingImage.jpg", naming_table) logger.warning( f"Could not find original name for {encrypted_path.name}, using {image_name}" ) @@ -340,11 +336,12 @@ class ImageRepository: return decoded_paths def decode_image( - self, encrypted_path: Path, decoded_path: Path | None, private_key: str | Path, hash_str: str + self, encrypted_path: Path, decoded_path: Path | None, private_key: str | Path, + hash_str: str | None ) -> bytes|None: encryption_manager = EncryptionManager() decrypted, hash = encryption_manager.decrypt(encrypted_path, decoded_path, private_key) - if hash != hash_str: + if hash_str and hash != hash_str: raise ValueError( f"Hash mismatch for {decoded_path}: expected {hash_str}, got {hash}" )