@@ -56,7 +56,10 @@ def compare(apk1, apk2) -> bool:
5656 zip1 = ZipFile (apk1 , "r" )
5757 zip2 = ZipFile (apk2 , "r" )
5858
59- return compare_entry_names (zip1 , zip2 ) and compare_entry_contents (zip1 , zip2 ) == True
59+ entry_names = compare_entry_names (zip1 , zip2 )
60+ entry_contents = compare_entry_contents (zip1 , zip2 )
61+
62+ return entry_names and entry_contents
6063
6164
6265def compare_entry_names (zip1 : ZipFile , zip2 : ZipFile ) -> bool :
@@ -70,27 +73,46 @@ def compare_entry_names(zip1: ZipFile, zip2: ZipFile) -> bool:
7073 while ignoreFile in name_list_sorted_2 :
7174 name_list_sorted_2 .remove (ignoreFile )
7275
76+ success = True
7377 if len (name_list_sorted_1 ) != len (name_list_sorted_2 ):
74- print ("Manifest lengths differ!" )
75-
76- for entry_name_1 , entry_name_2 in zip (name_list_sorted_1 , name_list_sorted_2 ):
77- if entry_name_1 != entry_name_2 :
78- print ("Sorted manifests don't match, %s vs %s" % (entry_name_1 , entry_name_2 ))
79- return False
78+ print (f"Manifest lengths differ! { len (name_list_sorted_1 )} vs { len (name_list_sorted_2 )} " )
79+ success = False
80+
81+ only_in_first = sorted (list (set (name_list_sorted_1 ) - set (name_list_sorted_2 )))
82+ only_in_second = sorted (list (set (name_list_sorted_2 ) - set (name_list_sorted_1 )))
83+
84+ if only_in_first :
85+ print (f"Files present only in { zip1 .filename } :" )
86+ for name in only_in_first :
87+ print (f" - { name } " )
88+ success = False
89+
90+ if only_in_second :
91+ print (f"Files present only in { zip2 .filename } :" )
92+ for name in only_in_second :
93+ print (f" - { name } " )
94+ success = False
95+
96+ # If sets are identical but ordering differs, still report ordering mismatches
97+ if success :
98+ for entry_name_1 , entry_name_2 in zip (name_list_sorted_1 , name_list_sorted_2 ):
99+ if entry_name_1 != entry_name_2 :
100+ print (f"Sorted manifests don't match: { entry_name_1 } vs { entry_name_2 } " )
101+ success = False
80102
81- return True
103+ return success
82104
83105
84106def compare_entry_contents (zip1 : ZipFile , zip2 : ZipFile ) -> bool :
85107 print ("Comparing zip entry contents..." )
86108 info_list_1 = list (filter (lambda info : info .filename not in IGNORE_FILES , zip1 .infolist ()))
87109 info_list_2 = list (filter (lambda info : info .filename not in IGNORE_FILES , zip2 .infolist ()))
88110
111+ success = True
89112 if len (info_list_1 ) != len (info_list_2 ):
90- print ("APK info lists of different length!" )
91- return False
113+ print (f "APK info lists of different length! { len ( info_list_1 ) } vs { len ( info_list_2 ) } " )
114+ success = False
92115
93- success = True
94116 for entry_info_1 in info_list_1 :
95117 for entry_info_2 in list (info_list_2 ):
96118 if entry_info_1 .filename == entry_info_2 .filename :
0 commit comments