From aa3c4488338d49d2502654c864ed4d465f5c09b0 Mon Sep 17 00:00:00 2001 From: themylogin Date: Wed, 24 Jul 2024 11:49:09 +0200 Subject: [PATCH] Do not crash if non-UTF-8 filenames are present in the upgraded BE --- truenas_install/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/truenas_install/__main__.py b/truenas_install/__main__.py index 6f53c51..3d2ed40 100644 --- a/truenas_install/__main__.py +++ b/truenas_install/__main__.py @@ -373,12 +373,13 @@ def main(): pass exclude_list = [] - for walk_root, dirs, files in os.walk(root): + root_as_bytes = root.encode() + for walk_root, dirs, files in os.walk(root_as_bytes): for file in files: - exclude_list.append(os.path.relpath(os.path.join(walk_root, file), root)) + exclude_list.append(os.path.relpath(os.path.join(walk_root, file), root_as_bytes)) with tempfile.NamedTemporaryFile() as exclude_list_file: - exclude_list_file.write("\n".join(exclude_list).encode("utf-8")) + exclude_list_file.write(b"\n".join(exclude_list)) exclude_list_file.flush() cmd = [