Fix symlink pruning not checking for directory links.
This commit is contained in:
parent
1511852e94
commit
0d918efe4c
1 changed files with 20 additions and 16 deletions
|
@ -253,14 +253,18 @@ def export_symlinks_argparse(args):
|
||||||
)
|
)
|
||||||
total_paths.update(export)
|
total_paths.update(export)
|
||||||
|
|
||||||
if args.prune and not args.dry_run:
|
if not args.prune or args.dry_run:
|
||||||
symlinks = set(file for file in spinal.walk_generator(destination) if file.is_link)
|
return
|
||||||
|
|
||||||
|
symlinks = spinal.walk_generator(destination, yield_directories=True, yield_files=True)
|
||||||
|
symlinks = set(path for path in symlinks if path.is_link)
|
||||||
symlinks = symlinks.difference(total_paths)
|
symlinks = symlinks.difference(total_paths)
|
||||||
for old_symlink in symlinks:
|
for old_symlink in symlinks:
|
||||||
print(f'Pruning {old_symlink}.')
|
print(f'Pruning {old_symlink}.')
|
||||||
os.remove(old_symlink.absolute_path)
|
os.remove(old_symlink.absolute_path)
|
||||||
if not old_symlink.parent.listdir():
|
if not old_symlink.parent.listdir():
|
||||||
os.rmdir(old_symlink.parent.absolute_path)
|
os.rmdir(old_symlink.parent.absolute_path)
|
||||||
|
|
||||||
checkdirs = set(spinal.walk_generator(destination, yield_directories=True, yield_files=False))
|
checkdirs = set(spinal.walk_generator(destination, yield_directories=True, yield_files=False))
|
||||||
while checkdirs:
|
while checkdirs:
|
||||||
check = checkdirs.pop()
|
check = checkdirs.pop()
|
||||||
|
|
Loading…
Reference in a new issue