From 75ea0204ff9308e5961c562efc36b4f3936a03c3 Mon Sep 17 00:00:00 2001 From: Maksim Totmin Date: Sun, 31 May 2026 18:47:36 +0700 Subject: [PATCH] Fix iTunesCDB header: always generate proper mhfd header - Remove broken header-preservation logic (was reusing all-zero header) - Always write header with correct total_size at offset 8 - Add version field 0x00020002 at offset 12 - Delete old iTunesDB (iTunesDB.old) to avoid firmware confusion --- src/ipod_nano7_db.py | 50 ++++++++++---------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/src/ipod_nano7_db.py b/src/ipod_nano7_db.py index 2b7ef8f..d9d7d10 100644 --- a/src/ipod_nano7_db.py +++ b/src/ipod_nano7_db.py @@ -1103,47 +1103,19 @@ class Nano7Database: # Compute new SHA1 hash new_hash = hashlib.sha1(lib_data).hexdigest() - # Read existing iTunesCDB to extract the header (first bytes before zlib) - if not os.path.exists(self.cdb_path): - header = b"\x00" * 244 - header = b"mhfd" + struct.pack("= 0: - break - if zlib_offset == -1: - logger.error("Could not find zlib header in iTunesCDB") - return + # Build proper mhfd header + header = bytearray(244) + header[0:4] = b"mhfd" + struct.pack_into("