Skip to content

Commit

Permalink
overwrite symbol link
Browse files Browse the repository at this point in the history
lrwxrwxrwx. 1 root root 20 Oct 17 13:17 /etc/mock/default.cfg ->
fedora-21-x86_64.cfg
lrwxrwxrwx. 1 root root 25 Nov 17 22:23 /etc/mock/default.cfg.rpmnew ->
fedora-rawhide-x86_64.cfg

Traceback (most recent call last):
  File "/sbin/rpmconf", line 318, in <module>
    main()
  File "/sbin/rpmconf", line 311, in main
    handle_package(args, package_hdr)
  File "/sbin/rpmconf", line 217, in handle_package
    handle_rpmnew(args, conf_file, conf_file + ".rpmnew")
  File "/sbin/rpmconf", line 159, in handle_rpmnew
    overwrite(args, other_file, conf_file)
  File "/sbin/rpmconf", line 43, in overwrite
    copy(src, dst)
  File "/sbin/rpmconf", line 35, in copy
    os.symlink(linkto, dst)
FileExistsError: [Errno 17] File exists: 'fedora-rawhide-x86_64.cfg' ->
'/etc/mock/default.cfg'

Reference: #11
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
  • Loading branch information
ignatenkobrain committed Nov 19, 2014
1 parent d800dce commit ff25ed5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/rpmconf.py
Expand Up @@ -16,6 +16,7 @@

import argparse
import difflib
import errno
import os
import pydoc
import re
Expand All @@ -35,7 +36,11 @@ def copy(src, dst):
""" Copy src to dst."""
if os.path.islink(src):
linkto = os.readlink(src)
os.symlink(linkto, dst)
try:
os.symlink(linkto, dst)
except FileExistsError:
os.unlink(dst)
os.symlink(linkto, dst)
else:
shutil.copy2(src, dst)

Expand Down

2 comments on commit ff25ed5

@ignatenkobrain
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I forget to remove this import. it's not needed. can you delete it? @xsuchy

@xsuchy
Copy link
Owner

@xsuchy xsuchy commented on ff25ed5 Nov 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Please sign in to comment.