symlink targets may exist; ignore them

This commit is contained in:
lilydjwg 2012-12-15 15:54:21 +08:00
parent e02972f610
commit 7f90c1a54c

View file

@ -225,8 +225,13 @@ class EventHandler(pyinotify.ProcessEvent):
newd = os.path.join(base, newarch)
newpath = os.path.join(newd, file)
if action == 'add':
os.symlink(os.path.join('..', arch, file), newpath)
self._real_dispatch(newd, ActionInfo(newpath, action))
try:
os.symlink(os.path.join('..', arch, file), newpath)
except FileExistsError:
# already there? do nothing then.
else:
# XXX: this should be removed as soon as symlinks are supported
self._real_dispatch(newd, ActionInfo(newpath, action))
else:
try:
os.unlink(newpath)