webdav: introduce CopyOptions

This commit is contained in:
Simon Ser
2023-12-15 15:16:01 +01:00
parent b043bbd965
commit 4493704689
4 changed files with 30 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ type FileSystem interface {
Create(ctx context.Context, name string) (io.WriteCloser, error)
RemoveAll(ctx context.Context, name string) error
Mkdir(ctx context.Context, name string) error
Copy(ctx context.Context, name, dest string, recursive, overwrite bool) (created bool, err error)
Copy(ctx context.Context, name, dest string, options *CopyOptions) (created bool, err error)
MoveAll(ctx context.Context, name, dest string, overwrite bool) (created bool, err error)
}
@@ -231,7 +231,11 @@ func (b *backend) Mkcol(r *http.Request) error {
}
func (b *backend) Copy(r *http.Request, dest *internal.Href, recursive, overwrite bool) (created bool, err error) {
created, err = b.FileSystem.Copy(r.Context(), r.URL.Path, dest.Path, recursive, overwrite)
options := CopyOptions{
NoRecursive: !recursive,
NoOverwrite: !overwrite,
}
created, err = b.FileSystem.Copy(r.Context(), r.URL.Path, dest.Path, &options)
if os.IsExist(err) {
return false, &internal.HTTPError{http.StatusPreconditionFailed, err}
}