3737# Create a threading lock
3838lock = threading .Lock ()
3939
40+ archive_exists = False
41+
4042
4143def get_relative_path (full_path : str ) -> str :
4244 """
@@ -100,6 +102,8 @@ def add_to_database(root_path: pathlib.Path, item: pathlib.Path) -> bool:
100102
101103 if content_database .does_archive_exist (archive_name , file_list ):
102104 logger .info (f"Archive '{ archive_name } ' already exists in the database." )
105+ global archive_exists
106+ archive_exists = True
103107 return True
104108 else :
105109 logger .info (f"Adding archive '{ archive_name } ' with { len (file_list )} files to the database." )
@@ -145,13 +149,16 @@ def process_manifest_and_target_folders(root_path, dirs, files, progressbar, cur
145149 if manifest_exists and folder .lower ().startswith ("content" ):
146150 content_path = root_path / folder
147151 clean_folder (content_path )
152+ progressbar .set (progressbar .get () + 0.1 )
148153 if add_to_database (content_path , current_item ):
154+ progressbar .set (progressbar .get () + 0.1 )
149155 return False
150156 shutil .copytree (content_path , get_library_path (), dirs_exist_ok = True )
151157 return True
152158
153159 if any (target .lower () == folder .lower () for target in TARGET_FOLDERS ):
154160 clean_folder (root_path )
161+ progressbar .set (progressbar .get () + 0.1 )
155162 if add_to_database (root_path , current_item ):
156163 return False
157164 shutil .copytree (root_path , get_library_path (), dirs_exist_ok = True )
@@ -165,10 +172,17 @@ def traverse_directory(folder_path: pathlib.Path, current_item: pathlib.Path, pr
165172 """
166173 for root , dirs , files in folder_path .walk ():
167174 root_path = pathlib .Path (root )
175+
168176 if handle_nested_archives (root_path , files , is_debug_mode ):
177+ progressbar .set (progressbar .get () + 0.1 )
169178 return traverse_directory (folder_path , current_item , progressbar , is_debug_mode )
170179 if process_manifest_and_target_folders (root_path , dirs , files , progressbar , current_item ):
180+ progressbar .set (progressbar .get () + 0.1 )
171181 return True
182+ if archive_exists :
183+ return False
184+ progressbar .set (progressbar .get () + 0.1 )
185+
172186 return False
173187
174188
0 commit comments