Opened 7 years ago

Closed 7 years ago

#4988 defect closed duplicate (duplicate)

filepath.FilePath.setContent should preserve permissions on target file

Reported by: Richard Wall Owned by: Richard Wall
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

setContent creates, writes and then renames a temporary file over the top of the original file...but it doesn't apply permissions that were present on the original file.

Furthermore, the mode flags passed to os.open, make the file executable.

This behaviour seems unexpected and is likely to confuse users of FilePath until they dig into the source code.

Seems like it should be fairly easy to read the mode from the original file and apply it to the new file.

>>> f = FilePath('foo')
>>> f.setContent('foo')
>>> f.restat()
>>> oct(f.statinfo.st_mode)
'0100755'
>>> f.chmod(0400)
>>> f.restat()
>>> oct(f.statinfo.st_mode)
'0100400'
>>> f.setContent('foo')
>>> f.restat()
>>> oct(f.statinfo.st_mode)
'0100755'

Change History (1)

comment:1 Changed 7 years ago by Richard Wall

Resolution: duplicate
Status: newclosed

Duplicate of #4360.

Note: See TracTickets for help on using tickets.