From 8190232c061223ef86e381fe762cc9dcf8420a00 Mon Sep 17 00:00:00 2001 From: Felipe Martin Garcia <812088+fmartingr@users.noreply.github.com> Date: Thu, 13 Oct 2022 23:11:52 +0200 Subject: [PATCH] feat: handle 404 on propfind (#57) Client.Stat was not returning a proper Go err for not found files, the ideal way to check this is using `errors.Is(err, fs.ErrNotExist)` but the client was returning a generic error. I've updated the `propfind` to take 404 errors into account, retuning the above error making easier to evaluate that kind of situations. --- requests.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/requests.go b/requests.go index ac33470..dbac928 100644 --- a/requests.go +++ b/requests.go @@ -130,7 +130,10 @@ func (c *Client) propfind(path string, self bool, body string, resp interface{}, } defer rs.Body.Close() - if rs.StatusCode != 207 { + switch rs.StatusCode { + case 207: + return newPathError("PROPFIND", path, rs.StatusCode) + case 404: return newPathError("PROPFIND", path, rs.StatusCode) }