From 26d4d348371fd51806ee07a77db7dcf96c973508 Mon Sep 17 00:00:00 2001 From: cha0sCat <47235156+cha0sCat@users.noreply.github.com> Date: Mon, 27 Apr 2020 10:01:00 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20webdav=20=E9=80=82=E9=85=8D=20rclone=20?= =?UTF-8?q?(#330)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rclone在传输时会反复创建父目录, 导致cloudreve返回409, 最终导致传输失败. 因此检测如果是rclone则忽略文目录已存在错误 --- pkg/webdav/webdav.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/webdav/webdav.go b/pkg/webdav/webdav.go index b5a1151..c859349 100644 --- a/pkg/webdav/webdav.go +++ b/pkg/webdav/webdav.go @@ -400,6 +400,11 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request, fs *filesy if r.ContentLength > 0 { return http.StatusUnsupportedMediaType, nil } + if strings.Contains(r.UserAgent(), "rclone") { + if _, ok := ctx.Value(fsctx.IgnoreConflictCtx).(bool); !ok { + ctx = context.WithValue(ctx, fsctx.IgnoreConflictCtx, true) + } + } if _, err := fs.CreateDirectory(ctx, reqPath); err != nil { return http.StatusConflict, err } -- GitLab