From 2217988f96bd881bc17d42560c83482e884eb92c Mon Sep 17 00:00:00 2001 From: vangef Date: Fri, 23 Feb 2024 18:06:04 +0000 Subject: [PATCH] (again) fix OSError: [WinError 6] The handle is invalid' - add try/except in rar file extractall() - possible issue with rar5 files --- utils/extractor.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/extractor.py b/utils/extractor.py index b4bbbc9..e511b5b 100644 --- a/utils/extractor.py +++ b/utils/extractor.py @@ -39,11 +39,10 @@ def extract_rar(rar_file: str, target_dir: str) -> None: rarfile.UNRAR_TOOL = 'unrar' files = rar_ref.namelist() files = [ f for f in files if "__MACOSX" not in f ] # filter out files with "__MACOSX" in the name - try: - rar_ref.extractall(target_dir, files) # extract the remaining files - rar_ref.close() - except OSError: - mark_file_as_BAD(rar_file, e) + rar_ref.extractall(target_dir, files) # extract the remaining files + rar_ref.close() + except OSError as e: + mark_file_as_BAD(rar_file, e) except rarfile.BadRarFile as e: mark_file_as_BAD(rar_file, e) except rarfile.NotRarFile as e: