Files module: Allow touch on hardlinks

This commit is contained in:
Jesse Buchanan 2014-12-07 13:35:24 -05:00 committed by Matt Clay
parent d88080007a
commit 06a58dcad7

View file

@ -336,13 +336,13 @@ def main():
open(path, 'w').close() open(path, 'w').close()
except OSError, e: except OSError, e:
module.fail_json(path=path, msg='Error, could not touch target: %s' % str(e)) module.fail_json(path=path, msg='Error, could not touch target: %s' % str(e))
elif prev_state in ['file', 'directory']: elif prev_state in ['file', 'directory', 'hard']:
try: try:
os.utime(path, None) os.utime(path, None)
except OSError, e: except OSError, e:
module.fail_json(path=path, msg='Error while touching existing target: %s' % str(e)) module.fail_json(path=path, msg='Error while touching existing target: %s' % str(e))
else: else:
module.fail_json(msg='Cannot touch other than files and directories') module.fail_json(msg='Cannot touch other than files, directories, and hardlinks (%s is %s)' % (path, prev_state))
try: try:
module.set_fs_attributes_if_different(file_args, True) module.set_fs_attributes_if_different(file_args, True)
except SystemExit, e: except SystemExit, e: