diff --git a/oa/libs/webdav/file.go b/oa/libs/webdav/file.go index 3cd19ff..df486bc 100644 --- a/oa/libs/webdav/file.go +++ b/oa/libs/webdav/file.go @@ -82,7 +82,7 @@ func (d Dir) Mkdir(ctx context.Context, name string, perm os.FileMode) error { if name = d.resolve(name); name == "" { return os.ErrNotExist } - return os.Mkdir(name, perm) + return os.MkdirAll(name, perm) } func (d Dir) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (File, error) { @@ -91,6 +91,13 @@ func (d Dir) OpenFile(ctx context.Context, name string, flag int, perm os.FileMo } f, err := os.OpenFile(name, flag, perm) if err != nil { + if os.IsNotExist(err) { + err = os.MkdirAll(filepath.Dir(name), 0777) + if err != nil { + return nil, err + } + return d.OpenFile(ctx, name, flag, perm) + } return nil, err } return f, nil