mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
add option for O_SYNC writes for standalone FS backend (#9581)
This commit is contained in:
@@ -24,8 +24,12 @@ import (
|
||||
)
|
||||
|
||||
// AppendFile - appends the file "src" to the file "dst"
|
||||
func AppendFile(dst string, src string) error {
|
||||
appendFile, err := os.OpenFile(dst, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
|
||||
func AppendFile(dst string, src string, osync bool) error {
|
||||
flags := os.O_WRONLY | os.O_APPEND | os.O_CREATE
|
||||
if osync {
|
||||
flags = flags | os.O_SYNC
|
||||
}
|
||||
appendFile, err := os.OpenFile(dst, flags, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
// AppendFile - appends the file "src" to the file "dst"
|
||||
func AppendFile(dst string, src string) error {
|
||||
func AppendFile(dst string, src string, osync bool) error {
|
||||
appendFile, err := lock.Open(dst, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestAppendFile(t *testing.T) {
|
||||
f.WriteString("bbbbbbbbbb")
|
||||
f.Close()
|
||||
|
||||
if err = AppendFile(name1, name2); err != nil {
|
||||
if err = AppendFile(name1, name2, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user