mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
lib/backup: properly create missing parent directories in fs.CreateFile
This commit is contained in:
parent
d120197676
commit
4e8d6b80e0
@ -209,10 +209,10 @@ func (fs *FS) DeleteFile(filePath string) error {
|
||||
//
|
||||
// The file is overwritten if it exists.
|
||||
func (fs *FS) CreateFile(filePath string, data []byte) error {
|
||||
if err := fs.mkdirAll(filePath); err != nil {
|
||||
path := filepath.Join(fs.Dir, filePath)
|
||||
if err := fs.mkdirAll(path); err != nil {
|
||||
return err
|
||||
}
|
||||
path := filepath.Join(fs.Dir, filePath)
|
||||
if err := ioutil.WriteFile(path, data, 0600); err != nil {
|
||||
return fmt.Errorf("cannot write %d bytes to %q: %s", len(data), path, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user