Merge pull request #43863 from nicholasmhughes/fix-atomicfile-permission-copy

Atomicfile only copies mode and not user/group perms
This commit is contained in:
Nicole Thomas 2017-11-10 11:47:54 -07:00 committed by GitHub
commit ed8da2450b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,8 @@ class _AtomicWFile(object):
self._fh.close()
if os.path.isfile(self._filename):
shutil.copymode(self._filename, self._tmp_filename)
st = os.stat(self._filename)
os.chown(self._tmp_filename, st.st_uid, st.st_gid)
atomic_rename(self._tmp_filename, self._filename)
def __exit__(self, exc_type, exc_value, traceback):