mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/backup: properly create missing parent directories in fs.CreateFile
This commit is contained in:
parent
ba1f764b29
commit
cf91a94daf
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue