diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py index 91e9fa444..6d321558a 100644 --- a/wcs/ctl/check_hobos.py +++ b/wcs/ctl/check_hobos.py @@ -186,9 +186,17 @@ class CmdCheckHobos(Command): atomic_symlink(target_dir, theme_dir) for component in ('static', 'templates'): component_dir = os.path.join(tenant_dir, component) - if os.path.lexists(component_dir): - os.unlink(component_dir) - if theme_data.get('overlay'): + if not os.path.islink(component_dir) and os.path.isdir(component_dir): + try: + os.rmdir(component_dir) + except OSError: + continue + if not theme_data.get('overlay'): + try: + os.unlink(component_dir) + except OSError: + pass + else: atomic_symlink( os.path.join(self.THEMES_DIRECTORY, theme_data['overlay'], component), component_dir)