Skip to content

Commit

Permalink
Remove existing .DirIcon before creating new symlink
Browse files Browse the repository at this point in the history

Remove .DirIcon symlink if it exists before creating the new symlink to avoid a FileExistsError exception.

This method of symlink replacement is not an atomic operation, but shouldn't be an issue in this case.
  • Loading branch information
lulol authored and azubieta committed Jun 28, 2022
1 parent 58cd38d commit d9f4ff0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion appimagebuilder/modules/setup/icon_bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def bundle_icon(self):
% (source_icon_path, os.path.relpath(target_icon_path, self.app_dir))
)
shutil.copyfile(source_icon_path, target_icon_path)
os.symlink(os.path.basename(source_icon_path), self.app_dir / ".DirIcon")
app_dir_icon_path = self.app_dir / ".DirIcon"
if os.path.exists(app_dir_icon_path):
os.remove(app_dir_icon_path)
os.symlink(os.path.basename(source_icon_path), app_dir_icon_path)
except Exception:
raise IconBundler.Error(
"Unable to copy icon from: %s to %s"
Expand Down

0 comments on commit d9f4ff0

Please sign in to comment.