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)
|
||||
|
||||
if args.prune and not args.dry_run:
|
||||
symlinks = set(file for file in spinal.walk_generator(destination) if file.is_link)
|
||||
if not args.prune or args.dry_run:
|
||||
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)
|
||||
for old_symlink in symlinks:
|
||||
print(f'Pruning {old_symlink}.')
|
||||
os.remove(old_symlink.absolute_path)
|
||||
if not old_symlink.parent.listdir():
|
||||
os.rmdir(old_symlink.parent.absolute_path)
|
||||
|
||||
checkdirs = set(spinal.walk_generator(destination, yield_directories=True, yield_files=False))
|
||||
while checkdirs:
|
||||
check = checkdirs.pop()
|
||||
|
|
Loading…
Reference in a new issue