diff options
| author | ebiggers <ebiggers@google.com> | 2019-09-09 13:41:32 -0700 |
|---|---|---|
| committer | Joseph Richey <joerichey@google.com> | 2019-09-09 13:41:32 -0700 |
| commit | 237308a671bd2bbea2059bea9e75cb1272edbdbf (patch) | |
| tree | 031a6383af9d0d6936c5ae85b998194b060a8c0e /metadata/policy.go | |
| parent | 6445dad7d66fa6a1867090fcd9602c98863649f6 (diff) | |
writeDataAtomic() fixes (#140)
* filesystem: ensure data is persisted before returning success
Sync the temporary file before renaming it, to ensure that after a
crash, the destination file isn't zero-length or otherwise incomplete.
Also sync the directory after the rename, to ensure the rename has been
persisted before returning success.
* filesystem: don't use fixed temporary file name
Using a fixed temporary file name in a world-writable sticky directory
is problematic since another user can create the file first.
Use ioutil.TempFile() to do it properly. It uses O_EXCL under the hood
to ensure the file is newly created.
Diffstat (limited to 'metadata/policy.go')
0 files changed, 0 insertions, 0 deletions