diff --git a/library/files/file b/library/files/file index ea47811656a..eb5cb089f9c 100644 --- a/library/files/file +++ b/library/files/file @@ -233,6 +233,8 @@ def main(): # try to replace atomically tmppath = '/'.join([os.path.dirname(path), ".%s.%s.tmp" % (os.getpid(),time.time())]) try: + if prev_state == 'directory' and (state == 'hard' or state == 'link'): + os.rmdir(path) if state == 'hard': os.link(src,tmppath) else: