mirror of
https://github.com/minio/minio.git
synced 2025-04-14 00:09:52 -04:00
Use O_EXCL when creating file as we never overwrite an existing file (#7189)
This commit is contained in:
parent
e9fdea05c6
commit
6f08edfb36
@ -1105,8 +1105,9 @@ func (s *posix) WriteAll(volume, path string, buf []byte) (err error) {
|
|||||||
return errFaultyDisk
|
return errFaultyDisk
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create file if not found
|
// Create file if not found. Note that it is created with os.O_EXCL flag as the file
|
||||||
w, err := s.openFile(volume, path, os.O_CREATE|os.O_SYNC|os.O_WRONLY)
|
// always is supposed to be created in the tmp directory with a unique file name.
|
||||||
|
w, err := s.openFile(volume, path, os.O_CREATE|os.O_SYNC|os.O_WRONLY|os.O_EXCL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -323,6 +323,11 @@ func TestHealing(t *testing.T) {
|
|||||||
t.Fatal("HealObject failed")
|
t.Fatal("HealObject failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = os.RemoveAll(path.Join(fsDirs[0], bucket, object, "xl.json"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Write xl.json with different modtime to simulate the case where a disk had
|
// Write xl.json with different modtime to simulate the case where a disk had
|
||||||
// gone down when an object was replaced by a new object.
|
// gone down when an object was replaced by a new object.
|
||||||
xlMetaOutDated := xlMetaPreHeal
|
xlMetaOutDated := xlMetaPreHeal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user