More robust write_text_file_atomic implementation
More robust write_text_file_atomic implementation

1. To make sure write appears atomic to observer we need to ensure that
os-level file descriptor is fsync'd before the rename.

2. Make sure the temporary file is removed in case of exceptions

Test plan:

$ sudo mount -t tmpfs -o size=1 tmpfs tmp
$ PYTHONPATH=py/phl python -c 'import phlsys_fs; phlsys_fs.write_text_file_atomic("tmp/filename","X"*100000)
$ sudo umount tmp

aevri/phabricator-tools,aevri/phabricator-tools,bloomberg/phabricator-tools,bloomberg/phabricator-tools,aevri/phabricator-tools,bloomberg/phabricator-tools,aevri/phabricator-tools,cs-shadow/phabricator-tools,cs-shadow/phabricator-tools,bloomberg/phabricator-tools,cs-shadow/phabricator-tools,bloomberg/phabricator-tools,cs-shadow/phabricator-tools,aevri/phabricator-tools,cs-shadow/phabricator-tools