Make sure we use O_EXCL with O_CREATE to make sure we don't trip over existing file

This commit is contained in:
Harshavardhana 2015-03-22 15:55:37 -07:00
parent b2ee7d989d
commit 3929135c34

View File

@ -8,7 +8,7 @@ import (
)
func newDonutFileWriter(objectDir string) (Writer, error) {
dataFile, err := os.OpenFile(path.Join(objectDir, "data"), os.O_WRONLY|os.O_CREATE, 0600)
dataFile, err := os.OpenFile(path.Join(objectDir, "data"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC|os.O_EXCL, 0600)
if err != nil {
return nil, err
}