diff --git a/fs_local.go b/fs_local.go index a3809f8..46b3983 100644 --- a/fs_local.go +++ b/fs_local.go @@ -66,6 +66,13 @@ func (fs LocalFileSystem) RemoveAll(name string) error { if err != nil { 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) } diff --git a/server.go b/server.go index d6fc4c9..1b4d80d 100644 --- a/server.go +++ b/server.go @@ -186,14 +186,9 @@ func (b *backend) Put(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 - // case the resource doesn't exist. We need to Stat before RemoveAll. - _, err := b.FileSystem.Stat(r.URL.Path) + err := b.FileSystem.RemoveAll(r.URL.Path) if os.IsNotExist(err) { return &internal.HTTPError{Code: http.StatusNotFound, Err: err} - } else if err != nil { - return err } - - return b.FileSystem.RemoveAll(r.URL.Path) + return err }