Эх сурвалжийг харах

Should only try to remove PTH link if it already exists.

Abraham Elmahrek 12 жил өмнө
parent
commit
1745fd2
1 өөрчлөгдсөн 5 нэмэгдсэн , 2 устгасан
  1. 5 2
      tools/app_reg/pth.py

+ 5 - 2
tools/app_reg/pth.py

@@ -100,12 +100,15 @@ class PthFile(object):
     file(tmp_path, 'w').write('\n'.join(sorted(self._entries)))
     os.rename(tmp_path, self._path)
     LOG.info('=== Saved %s' % self._path)
+
+    # relpath defined in common.py for python 2.4 and 2.5
     rel_symlink_path = os.path.relpath(self._path, os.path.dirname(self._symlink_path))
 
     # overwrite symlink if the path it points to is different from desired PTH.
-    # relpath defined in common.py for python 2.4 and 2.5
-    if not os.path.exists(self._symlink_path) or os.path.realpath(self._symlink_path) != rel_symlink_path:
+    if os.path.exists(self._symlink_path) and os.path.realpath(self._symlink_path) != rel_symlink_path:
       os.remove(self._symlink_path)
+
+    if not os.path.exists(self._symlink_path):
       os.symlink(rel_symlink_path, self._symlink_path)
       LOG.debug('=== Create symbolic link at %s to %s' % (self._symlink_path, rel_symlink_path))