mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/backup/fsremote: create all the parent directories before creating file in CreateFile
This commit is contained in:
parent
a1d841b33e
commit
8b0d9df51d
1 changed files with 3 additions and 0 deletions
|
@ -209,6 +209,9 @@ 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 {
|
||||
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