1
0
mirror of synced 2024-11-25 10:44:23 +01:00

Insert archive members in lexicographic order

This commit is contained in:
jvoisin 2018-09-18 22:44:21 +02:00
parent 9275d64be5
commit a1a06d023e

View File

@ -74,7 +74,9 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
temp_folder = tempfile.mkdtemp() temp_folder = tempfile.mkdtemp()
abort = False abort = False
for item in zin.infolist(): # Since files order is a fingerprint factor,
# we're iterating (and thus inserting) them in lexicographic order.
for item in sorted(zin.infolist(), key=lambda z: z.filename):
if item.filename[-1] == '/': # `is_dir` is added in Python3.6 if item.filename[-1] == '/': # `is_dir` is added in Python3.6
continue # don't keep empty folders continue # don't keep empty folders
@ -92,8 +94,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
pass pass
elif any(map(lambda r: r.search(item.filename), self.files_to_omit)): elif any(map(lambda r: r.search(item.filename), self.files_to_omit)):
continue continue
else: else: # supported files that we want to first clean, then add
# supported files that we want to clean then add
tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore
if not tmp_parser: if not tmp_parser:
if self.unknown_member_policy == UnknownMemberPolicy.OMIT: if self.unknown_member_policy == UnknownMemberPolicy.OMIT: