Skip to content

Commit a4aa133

Browse files
committed
walk loop now exists if archive is already in database and logging files only in debug mode
1 parent a3a604f commit a4aa133

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

content_database.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import threading
44
from pathlib import Path
55

6-
from helper.config_operations import get_library_path
7-
6+
from helper.config_operations import get_library_path, get_debug_mode
87

98
lock = threading.Lock()
109

@@ -101,7 +100,8 @@ def delete_archive(archive_name: str) -> None:
101100
try:
102101
if file_path.exists():
103102
file_path.unlink()
104-
logging.info(f"Deleted file: {file_path}")
103+
if get_debug_mode():
104+
logging.info(f"Deleted file: {file_path}")
105105
except Exception as e:
106106
logging.error(f"Error deleting file {file_path}: {e}")
107107

installer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
# Create a threading lock
3838
lock = threading.Lock()
3939

40+
archive_exists = False
41+
4042

4143
def 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

Comments
 (0)