1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

file: prevent replace failure when overwriting empty directory with hard/link (force=yes)

This commit is contained in:
RomanDolejsi 2014-07-29 10:46:32 +02:00
parent a9f0f8e975
commit fcf7f03398

View file

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