Skip to content

Commit

Permalink
fix(webdav): compatibiilty with Joplin (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Jul 24, 2024
1 parent ad12e88 commit 7ced6fe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion webdav/handler/method_mkcol.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package handler

import (
"errors"
"fmt"
"net/http"
"path"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7ced6fe

Please sign in to comment.