workers no longer crash on broken Unicode filenames
This commit is contained in:
parent
7e48c863c4
commit
ce5ebd7d97
2 changed files with 11 additions and 5 deletions
|
@ -33,8 +33,6 @@ if __name__ == "__main__":
|
|||
|
||||
# --------------------------------------------------
|
||||
# Create a list of all files
|
||||
|
||||
all_files = set()
|
||||
threads = [] # {proc, output_buffer}
|
||||
|
||||
for root in main.targets:
|
||||
|
@ -61,9 +59,17 @@ if __name__ == "__main__":
|
|||
|
||||
main.print("post-processing file list")
|
||||
|
||||
all_files = set()
|
||||
|
||||
for thread in threads:
|
||||
output = b"".join(thread["output_buffer"]).decode("utf-8")
|
||||
all_files.update(os.path.normpath(os.path.join(os.path.abspath(thread["root"]), f)) for f in output.split("\x00") if f)
|
||||
output = b"".join(thread["output_buffer"])
|
||||
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue