lib/backup/fsremote: create all the parent directories before creating file in CreateFile

This commit is contained in:
Aliaksandr Valialkin 2020-06-05 10:24:51 +03:00
parent a1d841b33e
commit 8b0d9df51d

View file

@ -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)