From 7cd6d6fb89f0dde5e77e826f41f0bc9c5b75c252 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) --- files/file | 2 ++ 1 file changed, 2 insertions(+) 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: