add comments.

This commit is contained in:
Mohanson
2018-04-03 16:51:30 +08:00
committed by GitHub
parent 2fbd9f15fa
commit 29a8cb8d87

View File

@@ -148,6 +148,9 @@ func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
} else if n < len(data) {
return io.ErrShortWrite
}
// Close the file before renaming it, otherwise it will cause "The process
// cannot access the file because it is being used by another process." on windows or
// cause "cross-link error" on linux when you try to save it to another partition.
f.Close()
return os.Rename(f.Name(), filename)