diff --git a/files/file b/files/file index ea47811656a..eb5cb089f9c 100644 --- a/files/file +++ b/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: