bug fix: WriteFileAtomic

Must close file before rename it.
This commit is contained in:
Mohanson 2018-04-03 15:26:47 +08:00 committed by GitHub
parent 24da7009c3
commit 2fbd9f15fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,6 +148,7 @@ func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
} else if n < len(data) {
return io.ErrShortWrite
}
f.Close()
return os.Rename(f.Name(), filename)
}