From 1d8889721e9d659831c6bc6e9af9a3497b76e691 Mon Sep 17 00:00:00 2001 From: jteulade Date: Thu, 7 Mar 2024 16:55:00 +0100 Subject: [PATCH] Fix: zip can contain directories and files at the root --- sertit/files.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sertit/files.py b/sertit/files.py index 5539393..1169b0f 100644 --- a/sertit/files.py +++ b/sertit/files.py @@ -200,7 +200,8 @@ def extract_file( if file_path.suffix == ".zip": # Manage the case with several directories inside one zipfile arch = zipfile.ZipFile(file_path, "r") - extr_names = list({p.split("/")[0] for p in arch.namelist()}) + # extr_names contains only directory names + extr_names = list({p.split("/")[0] for p in arch.namelist() if "/" in p}) elif file_path.suffix == ".tar" or file_path.suffixes == [".tar", ".gz"]: # Tar files have no subdirectories, so create one extr_names = [path.get_filename(file_path)]