Merge pull request #216 from Jomolungma/215-missing-contacts-database

Fix for bug 215, ignore missing contacts database.in encrypted iOS backups.
This commit is contained in:
Knugi
2026-07-05 19:36:07 +08:00
committed by GitHub
+21 -14
View File
@@ -101,26 +101,14 @@ class BackupExtractor:
decrypt_chunk_size=self.decrypt_chunk_size, decrypt_chunk_size=self.decrypt_chunk_size,
) )
logging.info(f"iOS backup is opened successfully") logging.info(f"iOS backup is opened successfully")
logging.info("Decrypting WhatsApp database...", extra={"clear": True}) logging.info("Decrypting WhatsApp database...")
try:
try: try:
self.backup.extract_file( self.backup.extract_file(
relative_path=RelativePath.WHATSAPP_MESSAGES, relative_path=RelativePath.WHATSAPP_MESSAGES,
domain_like=self.identifiers.DOMAIN, domain_like=self.identifiers.DOMAIN,
output_filename=self.identifiers.MESSAGE, output_filename=self.identifiers.MESSAGE,
) )
self.backup.extract_file(
relative_path=RelativePath.WHATSAPP_CONTACTS,
domain_like=self.identifiers.DOMAIN,
output_filename=self.identifiers.CONTACT,
)
self.backup.extract_file(
relative_path=RelativePath.WHATSAPP_CALLS,
domain_like=self.identifiers.DOMAIN,
output_filename=self.identifiers.CALL,
)
except ValueError:
logging.error("Failed to decrypt backup: incorrect password?")
exit(7)
except FileNotFoundError: except FileNotFoundError:
logging.error( logging.error(
"Essential WhatsApp files are missing from the iOS backup. " "Essential WhatsApp files are missing from the iOS backup. "
@@ -128,6 +116,25 @@ class BackupExtractor:
"See https://wts.knugi.dev/docs.html?dest=iose2e" "See https://wts.knugi.dev/docs.html?dest=iose2e"
) )
exit(6) exit(6)
try:
self.backup.extract_file(
relative_path=RelativePath.WHATSAPP_CONTACTS,
domain_like=self.identifiers.DOMAIN,
output_filename=self.identifiers.CONTACT,
)
except FileNotFoundError:
logging.warning(f"Contact database not found. Skipping...")
try:
self.backup.extract_file(
relative_path=RelativePath.WHATSAPP_CALLS,
domain_like=self.identifiers.DOMAIN,
output_filename=self.identifiers.CALL,
)
except FileNotFoundError:
logging.warning(f"Call database not found. Skipping...")
except ValueError:
logging.error("Failed to decrypt backup: incorrect password?")
exit(7)
else: else:
logging.info(f"WhatsApp database decrypted successfully") logging.info(f"WhatsApp database decrypted successfully")