From 0841a1a47816365df5dce33a9b6d6e6f104cebde Mon Sep 17 00:00:00 2001 From: vangef Date: Fri, 23 Feb 2024 18:03:13 +0000 Subject: [PATCH] fix OSError: [WinError 6] The handle is invalid' - add try/except in rar file extractall() - possible issue with rar5 files --- utils/extractor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/extractor.py b/utils/extractor.py index 71ba6a3..b4bbbc9 100644 --- a/utils/extractor.py +++ b/utils/extractor.py @@ -39,8 +39,11 @@ 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 - rar_ref.extractall(target_dir, files) # extract the remaining files - rar_ref.close() + try: + rar_ref.extractall(target_dir, files) # extract the remaining files + rar_ref.close() + except OSError: + mark_file_as_BAD(rar_file, e) except rarfile.BadRarFile as e: mark_file_as_BAD(rar_file, e) except rarfile.NotRarFile as e: