Skip to content

Commit

Permalink
Create symbolic link only if the target exists
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Sep 4, 2024
1 parent b71557e commit acd7190
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions weechat/download/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ def handler_package_saved(sender, **kwargs):

def make_symlink(link_name, target):
"""Create a symbolic link (overwrite link_name if existing)."""
print(f'Making symlink: {link_name} -> {target}')
tmp_name = f'{link_name}.__tmp__'
os.symlink(target, tmp_name)
os.rename(tmp_name, link_name)
if os.path.exists(target):
print(f'Making symlink: {link_name} -> {target}')
tmp_name = f'{link_name}.__tmp__'
os.symlink(target, tmp_name)
os.rename(tmp_name, link_name)


def set_stable_version(project, version):
Expand Down

0 comments on commit acd7190

Please sign in to comment.