Skip to content

Conversation

@Tokenzrey
Copy link

Previously, the script hardcoded queries to the ZASSET table (standard in iOS 13+). iOS 12 uses ZGENERICASSET. This PR implements dynamic table detection to support both schema versions and adds error handling for corrupted databases.

Changes

  • Added: get_asset_table_name(db_path) helper function to check sqlite_master for ZASSET or ZGENERICASSET.
  • Updated: get_photosDbexif now uses the detected table name to build the SQL query dynamically.
  • Added: try-except blocks around the main query execution to prevent crashes on malformed databases.
  • Result: Restores full functionality for iOS 12 backups while maintaining support for iOS 13+.

Verification & Testing

I have created a comprehensive test suite (test_photosDbexif_fix.py) to verify the fix across different schema versions.

  • Test Suite: 4/4 tests passed.
  • Scenarios Covered:
    • Modern iOS (iOS 13+): Verifies ZASSET detection and querying.
    • Legacy iOS (iOS 12): Verifies ZGENERICASSET detection and querying (The Fix).
    • Corrupted DB: Verifies graceful degradation when no asset table exists.
    • Bug Reproduction: Confirms the original code fails on iOS 12 schemas.

Test Output Summary:

TEST SUMMARY
================================================================================
Modern iOS (ZASSET Table)......................... [PASS]
Legacy iOS (ZGENERICASSET Table).................. [PASS]
Corrupted DB (No Asset Table)..................... [PASS]
Original Bug Demonstration........................ [PASS]
================================================================================
Total: 4/4 tests passed
[SUCCESS] ALL TESTS PASSED - photosDbexif fix is working!

Checklist

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have verified the fix with a local test script.
  • The changes generate no new warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant