From fcf7f03398536b1ee0e205783c851121899d8f13 Mon Sep 17 00:00:00 2001 From: RomanDolejsi Date: Tue, 29 Jul 2014 10:46:32 +0200 Subject: [PATCH] file: prevent replace failure when overwriting empty directory with hard/link (force=yes) --- library/files/file | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/files/file b/library/files/file index ea47811656..eb5cb089f9 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: