mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
webdav: move WebDAV semantics handling to LocalFileSystem
This commit is contained in:
parent
04bcea1ee8
commit
a2ad695145
@ -66,6 +66,13 @@ func (fs LocalFileSystem) RemoveAll(name string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WebDAV semantics are that it should return a "404 Not Found" error in
|
||||||
|
// case the resource doesn't exist. We need to Stat before RemoveAll.
|
||||||
|
if _, err = os.Stat(p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return os.RemoveAll(p)
|
return os.RemoveAll(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,14 +186,9 @@ func (b *backend) Put(r *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *backend) Delete(r *http.Request) error {
|
func (b *backend) Delete(r *http.Request) error {
|
||||||
// WebDAV semantics are that it should return a "404 Not Found" error in
|
err := b.FileSystem.RemoveAll(r.URL.Path)
|
||||||
// case the resource doesn't exist. We need to Stat before RemoveAll.
|
|
||||||
_, err := b.FileSystem.Stat(r.URL.Path)
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return &internal.HTTPError{Code: http.StatusNotFound, Err: err}
|
return &internal.HTTPError{Code: http.StatusNotFound, Err: err}
|
||||||
} else if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
return b.FileSystem.RemoveAll(r.URL.Path)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user