webdav: add MOVE support to server

This commit is contained in:
Simon Ser
2020-01-22 11:43:36 +01:00
parent 83cb67070c
commit 3268102d5a
4 changed files with 87 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ type FileSystem interface {
Create(name string) (io.WriteCloser, error)
RemoveAll(name string) error
Mkdir(name string) error
MoveAll(name, dest string, overwrite bool) (created bool, err error)
}
// Handler handles WebDAV HTTP requests. It can be used to create a WebDAV
@@ -213,3 +214,11 @@ func (b *backend) Mkcol(r *http.Request) error {
}
return err
}
func (b *backend) Move(r *http.Request, dest *internal.Href, overwrite bool) (created bool, err error) {
created, err = b.FileSystem.MoveAll(r.URL.Path, dest.Path, overwrite)
if os.IsExist(err) {
return false, &internal.HTTPError{http.StatusPreconditionFailed, err}
}
return created, err
}