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
+10
-13
@@ -245,24 +245,20 @@ class ImageRepository:
|
|||||||
raise FileNotFoundError("No naming table found")
|
raise FileNotFoundError("No naming table found")
|
||||||
decoded_paths = []
|
decoded_paths = []
|
||||||
sources_to_remove = []
|
sources_to_remove = []
|
||||||
|
|
||||||
for encrypted_path in encrypted_images:
|
for encrypted_path in encrypted_images:
|
||||||
if self._is_jpg(encrypted_path):
|
if self._is_jpg(encrypted_path):
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
image_name,image_hash = next(
|
image_name, image_hash = next(
|
||||||
(item.image_name,item.image_hash)
|
(item.image_name, item.image_hash)
|
||||||
for item in naming_table
|
for item in naming_table
|
||||||
if item.encrypted_file == encrypted_path.name
|
if item.encrypted_file == encrypted_path.name
|
||||||
)
|
)
|
||||||
|
except StopIteration:
|
||||||
|
image_name = None
|
||||||
|
image_hash = None
|
||||||
if image_name is None:
|
if image_name is None:
|
||||||
image_name = self._find_name_in_legacy_tables(encrypted_path.name)
|
image_name = self._unique_identifier("MissingImage.jpg", naming_table)
|
||||||
logger.warning(
|
|
||||||
f"Could not find original name for {encrypted_path.name} in naming table, "
|
|
||||||
f"checking legacy tables: {image_name}"
|
|
||||||
)
|
|
||||||
if image_name is None:
|
|
||||||
image_name = f"Sexy_MISSING_{len(decoded_paths) + 1}.jpg"
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Could not find original name for {encrypted_path.name}, using {image_name}"
|
f"Could not find original name for {encrypted_path.name}, using {image_name}"
|
||||||
)
|
)
|
||||||
@@ -340,11 +336,12 @@ class ImageRepository:
|
|||||||
return decoded_paths
|
return decoded_paths
|
||||||
|
|
||||||
def decode_image(
|
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:
|
) -> bytes|None:
|
||||||
encryption_manager = EncryptionManager()
|
encryption_manager = EncryptionManager()
|
||||||
decrypted, hash = encryption_manager.decrypt(encrypted_path, decoded_path, private_key)
|
decrypted, hash = encryption_manager.decrypt(encrypted_path, decoded_path, private_key)
|
||||||
if hash != hash_str:
|
if hash_str and hash != hash_str:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Hash mismatch for {decoded_path}: expected {hash_str}, got {hash}"
|
f"Hash mismatch for {decoded_path}: expected {hash_str}, got {hash}"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user