workers no longer crash on broken Unicode filenames

This commit is contained in:
Martinez 2017-12-25 14:54:49 +01:00
parent 7e48c863c4
commit ce5ebd7d97
2 changed files with 11 additions and 5 deletions

View file

@ -33,8 +33,6 @@ if __name__ == "__main__":
# -------------------------------------------------- # --------------------------------------------------
# Create a list of all files # Create a list of all files
all_files = set()
threads = [] # {proc, output_buffer} threads = [] # {proc, output_buffer}
for root in main.targets: for root in main.targets:
@ -61,9 +59,17 @@ if __name__ == "__main__":
main.print("post-processing file list") main.print("post-processing file list")
all_files = set()
for thread in threads: for thread in threads:
output = b"".join(thread["output_buffer"]).decode("utf-8") output = b"".join(thread["output_buffer"])
all_files.update(os.path.normpath(os.path.join(os.path.abspath(thread["root"]), f)) for f in output.split("\x00") if f) for raw_name in output.split(b"\x00"):
try:
name = raw_name.decode("utf-8")
except UnicodeDecodeError:
main.print("UTF-8 decoding failed: <R>%s<.>" %(repr(raw_name)), main.print.tl.fail)
all_files.add(os.path.normpath(os.path.join(os.path.abspath(thread["root"]), name)))
main.print("found %d files" %(len(all_files)), main.print.tl.done) main.print("found %d files" %(len(all_files)), main.print.tl.done)

View file

@ -4,5 +4,5 @@
major = 0 # VERSION_MAJOR_IDENTIFIER major = 0 # VERSION_MAJOR_IDENTIFIER
minor = 2 # VERSION_MINOR_IDENTIFIER minor = 2 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 0.2 # VERSION_LAST_MM 0.2
patch = 2 # VERSION_PATCH_IDENTIFIER patch = 3 # VERSION_PATCH_IDENTIFIER
str = ".".join(str(v) for v in (major, minor, patch)) str = ".".join(str(v) for v in (major, minor, patch))