Skip to content

Commit ea6fd68

Browse files
Another folder headache fix
1 parent e137ffb commit ea6fd68

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

DAZFix/LibraryFix.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,30 @@ def move_to_new_home(dupe_dirs_folder, dest_full_path, root):
4848
# TheFolder/Characters/Characters....FML
4949
if os.path.isdir(destination):
5050
if os.path.isdir(source):
51-
for file in os.listdir(source):
52-
src = os.path.join(source, file)
53-
dest = os.path.join(destination, file)
54-
log_to_ui(f'Moving {src} => {destination}')
55-
56-
if os.path.isdir(source):
57-
shutil.move(src, dest)
51+
for obj in os.listdir(source):
52+
src = os.path.join(source, obj)
53+
dest = os.path.join(destination, obj)
54+
55+
if os.path.isdir(src):
56+
log_to_ui(f'Moving FOLDER: {src} => {dest}')
57+
shutil.copytree(src, dest, dirs_exist_ok=True)
5858
else:
59+
log_to_ui(f'Moving FILE: {src} => {dest}')
5960
shutil.copy2(src, dest)
6061

6162
else:
6263
log_to_ui(f'Moving {obj} => {destination}')
6364
shutil.move(source, destination)
6465

6566
# Now that all the files are moved out, delete the directory
66-
if os.path.isdir(dupe_folder_path):
67+
if os.path.exists(dupe_folder_path):
68+
log_to_ui(f'Removing folder: {dupe_folder_path}:')
69+
for obj in os.listdir(dupe_folder_path):
70+
# Indent to indicate objects within the folder that were removed (after being copied)
71+
log_to_ui(" " + obj)
6772
shutil.rmtree(dupe_folder_path)
6873

74+
6975
def make_archive(source, destination):
7076
base = os.path.basename(destination)
7177
name = base.split('.')[0]
@@ -78,7 +84,7 @@ def make_archive(source, destination):
7884

7985

8086
def fix_libraries(backup_first, backup_zip_path, daz_default_library_path, daz_user_library_path):
81-
log_to_ui("Fixing libraries...")
87+
log_to_ui("\nFixing libraries...")
8288
if globals.process_running:
8389
return
8490

@@ -195,7 +201,7 @@ def fix_libraries(backup_first, backup_zip_path, daz_default_library_path, daz_u
195201

196202
# Here we just need to rename to the default case
197203
# This may have been addressed by the fix to the user's library above, so check...
198-
if old_path:
204+
if os.path.exists(old_path):
199205
os.rename(old_path, new_path)
200206

201207
globals.process_running = False

0 commit comments

Comments
 (0)