From ce5ebd7d97278888f9afd5202598d01426672186 Mon Sep 17 00:00:00 2001 From: Martinez Date: Mon, 25 Dec 2017 14:54:49 +0100 Subject: [PATCH] workers no longer crash on broken Unicode filenames --- find-orphans.py | 14 ++++++++++---- version.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/find-orphans.py b/find-orphans.py index c84ad3b..7a8533e 100755 --- a/find-orphans.py +++ b/find-orphans.py @@ -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: %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) diff --git a/version.py b/version.py index 65cede7..da2d720 100644 --- a/version.py +++ b/version.py @@ -4,5 +4,5 @@ major = 0 # VERSION_MAJOR_IDENTIFIER minor = 2 # VERSION_MINOR_IDENTIFIER # 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))