From f77bfd7b794a3e172f57d95a62639a0314898bc6 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Tue, 27 Aug 2024 09:51:48 +0200 Subject: [PATCH] fix: Get filepath for checking overwrite Signed-off-by: Vincent Boutour --- pkg/crud/post.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/crud/post.go b/pkg/crud/post.go index a92a124d..c7b3d276 100644 --- a/pkg/crud/post.go +++ b/pkg/crud/post.go @@ -117,14 +117,14 @@ func (s Service) handleMultipart(w http.ResponseWriter, r *http.Request, request } if values["overwrite"] != "true" { - fileName, err := safeFilename(values["filename"]) + _, filePath, err := getUploadNameAndPath(request, values["filename"], file) if err != nil { s.error(w, r, request, model.WrapInvalid(err)) return } - if _, err := s.storage.Stat(ctx, request.SubPath(fileName)); err == nil { - s.error(w, r, request, model.WrapInvalid(fmt.Errorf("filename `%s`: %w", fileName, ErrFileAlreadyExists))) + if _, err := s.storage.Stat(ctx, filePath); err == nil { + s.error(w, r, request, model.WrapInvalid(fmt.Errorf("filename `%s`: %w", filePath, ErrFileAlreadyExists))) return } }