webdav: add COPY support to server

This commit is contained in:
Simon Ser
2020-01-22 13:00:42 +01:00
parent fda38c8f93
commit 6d229f4e8a
4 changed files with 131 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ type FileSystem interface {
Create(name string) (io.WriteCloser, error)
RemoveAll(name string) error
Mkdir(name string) error
Copy(name, dest string, recursive, overwrite bool) (created bool, err error)
MoveAll(name, dest string, overwrite bool) (created bool, err error)
}
@@ -223,6 +224,14 @@ func (b *backend) Mkcol(r *http.Request) error {
return err
}
func (b *backend) Copy(r *http.Request, dest *internal.Href, recursive, overwrite bool) (created bool, err error) {
created, err = b.FileSystem.Copy(r.URL.Path, dest.Path, recursive, overwrite)
if os.IsExist(err) {
return false, &internal.HTTPError{http.StatusPreconditionFailed, err}
}
return created, 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) {