mirror of https://github.com/ansible/ansible.git
Fix jsonfile cache on WSL (#85816)
On WSL, `os.rename` can't correctly move a file while a handle to that file is still open. It remains half-moved where neither the source or destination seem to exist (according to `os.path.exists`). However the move seems to complete correctly when the open handle is closed. In `BaseFileCacheModule`, when writing a cache file, a temporary file is created with `mkstemp` that returns an open file descriptor and a filename. Once the cache is written to that file, it is renamed to the correct file name with `os.rename` and then its permissions set with `os.chmod`. On WSL the `os.chmod` fails because it doesn't think the file exists yet because the file descriptor returned by `mkstemp` is still open. This PR fixes this by closing that file descriptor before renaming. Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>pull/85670/merge
parent
967d654ef6
commit
e30da51731
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- cache plugins - close temp cache file before moving it to fix error on WSL. (https://github.com/ansible/ansible/pull/85816)
|
||||
Loading…
Reference in New Issue