Files are normally created with permission 666 & umask as expected:
>>> click.open_file('/tmp/test1', 'w').close()
>>> oct(os.stat('/tmp/test1').st_mode)
'0o100644'
However, opening a new or existing file with atomic=True sets or resets its permissions to 600 unconditionally:
>>> click.open_file('/tmp/test2', 'w', atomic=True).close()
>>> oct(os.stat('/tmp/test2').st_mode)
'0o100600'
>>> click.open_file('/tmp/test1', 'w', atomic=True).close()
>>> oct(os.stat('/tmp/test1').st_mode)
'0o100600'
I’d expect a new file created with atomic=True to be created with the usual permission 666 & umask, and an existing file opened with atomic=True to have the previous permissions preserved. (There’s probably no way to preserve permissions atomically; taking the previous permissions at the time of the initial open is fine.)
Files are normally created with permission
666 & umaskas expected:However, opening a new or existing file with
atomic=Truesets or resets its permissions to600unconditionally:I’d expect a new file created with
atomic=Trueto be created with the usual permission666 & umask, and an existing file opened withatomic=Trueto have the previous permissions preserved. (There’s probably no way to preserve permissions atomically; taking the previous permissions at the time of the initial open is fine.)