From 7ced6fec6124e010171a347fd03b4476e96bf47b Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Wed, 24 Jul 2024 13:35:52 +0200 Subject: [PATCH] fix(webdav): compatibiilty with Joplin (#223) --- webdav/handler/method_mkcol.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webdav/handler/method_mkcol.go b/webdav/handler/method_mkcol.go index 248124fde..ea1377161 100644 --- a/webdav/handler/method_mkcol.go +++ b/webdav/handler/method_mkcol.go @@ -11,6 +11,7 @@ package handler import ( + "errors" "fmt" "net/http" "path" @@ -50,7 +51,17 @@ func (h *Handler) methodMkcol(w http.ResponseWriter, r *http.Request) { ParentID: directory.ID, Name: helper.DecodeURIComponent(path.Base(r.URL.Path)), }); err != nil { - infra.HandleError(err, w) + var apiError *infra.APIError + if errors.As(err, &apiError) { + if apiError.Value.Code == "file_with_similar_name_exists" && apiError.Value.Status == http.StatusForbidden { + // No-op + return + } else { + infra.HandleError(err, w) + } + } else { + infra.HandleError(err, w) + } return } w.WriteHeader(http.StatusCreated)