mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Fix a potential file leak
Previously, if a write or sync error occurred, we would not have called Close(). This commit refactors ReplaceFile() so that we are sure to call Close(), and also attempts to delete the temporary file if errors occur.
This commit is contained in:
@@ -31,6 +31,7 @@ type Filesystem interface {
|
||||
MkdirAll(path string, perm os.FileMode) error
|
||||
Chtimes(name string, atime time.Time, mtime time.Time) error
|
||||
RemoveAll(path string) error
|
||||
Remove(name string) error
|
||||
|
||||
// from "io/ioutil"
|
||||
ReadFile(filename string) ([]byte, error)
|
||||
|
||||
Reference in New Issue
Block a user