@@ -70,9 +70,7 @@ def extract_archive(item_path, is_debug_mode):
7070def clean_folder (folder_path ):
7171 for item_path in pathlib .Path (folder_path ).iterdir ():
7272 item = item_path .name
73- if item_path .is_dir () and item not in target_folders :
74- shutil .rmtree (item_path )
75- elif item_path .is_file ():
73+ if item_path .is_file ():
7674 item_path .unlink ()
7775
7876def add_to_database (root_path , item ):
@@ -94,8 +92,9 @@ def add_to_database(root_path, item):
9492
9593
9694# Searching the content of extracted archive for target folders
97- def traverse_directory (folder_path , current_item , progressbar , is_debug_mode ):
95+ def traverse_directory (folder_path , current_item , progressbar , is_debug_mode , is_nested_archive = False ):
9896 archive_extracted = False
97+ manifest_exists = False
9998 for root , dirs , files in pathlib .Path (folder_path ).walk ():
10099 for file in files :
101100 if file .lower ().endswith (('.zip' , '.rar' , '7z' , '.tar' )):
@@ -106,10 +105,24 @@ def traverse_directory(folder_path, current_item, progressbar, is_debug_mode):
106105 time .sleep (0.5 )
107106 pathlib .Path (root ).joinpath (file ).unlink ()
108107 archive_extracted = True
108+ if file .lower ().endswith ("manifest.dsx" ):
109+ manifest_exists = True
110+
109111 progressbar .set (progressbar .get () + 0.1 )
110112 if archive_extracted :
111113 progressbar .set (progressbar .get ()+ 0.1 )
112- return traverse_directory (folder_path , current_item , progressbar , is_debug_mode )
114+ is_nested_archive = archive_extracted
115+ return traverse_directory (folder_path , current_item , progressbar , is_debug_mode , is_nested_archive )
116+ if manifest_exists :
117+ for folder in dirs :
118+ if folder .lower ().startswith ("content" ):
119+ content_path = pathlib .Path (str (root )).joinpath (folder )
120+ progressbar .set (0.9 )
121+ clean_folder (content_path )
122+ if add_to_database (content_path , current_item ):
123+ return False
124+ shutil .copytree (content_path , get_library_path (), dirs_exist_ok = True )
125+ return True
113126 if any (target in dirs for target in target_folders ):
114127 progressbar .set (0.9 )
115128 clean_folder (root )
0 commit comments