feat(wallpaper_changer): decode_all should decode lonley jpg_enc with default name
This commit is contained in:
1 parent
f8627a946d
commit
7ebead0b53
1 file changed
+12
-15
@@ -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}"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user