diff options
Diffstat (limited to 'cmd/git-lfs-server')
-rw-r--r-- | cmd/git-lfs-server/main.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cmd/git-lfs-server/main.go b/cmd/git-lfs-server/main.go index dcc24b2..191a696 100644 --- a/cmd/git-lfs-server/main.go +++ b/cmd/git-lfs-server/main.go | |||
@@ -606,20 +606,19 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
606 | reqPath = strings.TrimPrefix(path.Clean(reqPath), "/") | 606 | reqPath = strings.TrimPrefix(path.Clean(reqPath), "/") |
607 | 607 | ||
608 | if submatches := reBatchAPI.FindStringSubmatch(reqPath); len(submatches) == 2 { | 608 | if submatches := reBatchAPI.FindStringSubmatch(reqPath); len(submatches) == 2 { |
609 | repo := strings.TrimPrefix(path.Clean(submatches[1]), "/") | ||
610 | reqlog(ctx, "Repository: %s", repo) | ||
611 | |||
612 | if r.Method != http.MethodPost { | 609 | if r.Method != http.MethodPost { |
613 | makeRespError(ctx, w, "Method not allowed", http.StatusMethodNotAllowed) | 610 | makeRespError(ctx, w, "Method not allowed", http.StatusMethodNotAllowed) |
614 | return | 611 | return |
615 | } | 612 | } |
616 | 613 | ||
614 | repo := strings.TrimPrefix(path.Clean(submatches[1]), "/") | ||
615 | reqlog(ctx, "Handling batch API request for repository: %s", repo) | ||
616 | |||
617 | h.handleBatchAPI(w, r.WithContext(ctx), repo) | 617 | h.handleBatchAPI(w, r.WithContext(ctx), repo) |
618 | return | 618 | return |
619 | } | 619 | } |
620 | 620 | ||
621 | if submatches := reObjUpload.FindStringSubmatch(reqPath); len(submatches) == 5 { | 621 | if submatches := reObjUpload.FindStringSubmatch(reqPath); len(submatches) == 5 { |
622 | repo := strings.TrimPrefix(path.Clean(submatches[1]), "/") | ||
623 | oid0, oid1, oid := submatches[2], submatches[3], submatches[4] | 622 | oid0, oid1, oid := submatches[2], submatches[3], submatches[4] |
624 | 623 | ||
625 | if !isValidSHA256Hash(oid) { | 624 | if !isValidSHA256Hash(oid) { |
@@ -629,7 +628,9 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
629 | makeRespError(ctx, w, "Bad URL format: malformed OID pattern", http.StatusBadRequest) | 628 | makeRespError(ctx, w, "Bad URL format: malformed OID pattern", http.StatusBadRequest) |
630 | return | 629 | return |
631 | } | 630 | } |
632 | reqlog(ctx, "Repository: %s; OID: %s", repo, oid) | 631 | |
632 | repo := strings.TrimPrefix(path.Clean(submatches[1]), "/") | ||
633 | reqlog(ctx, "Handling object PUT for repository: %s, OID: %s", repo, oid) | ||
633 | 634 | ||
634 | if r.Method != http.MethodPut { | 635 | if r.Method != http.MethodPut { |
635 | makeRespError(ctx, w, "Method not allowed", http.StatusMethodNotAllowed) | 636 | makeRespError(ctx, w, "Method not allowed", http.StatusMethodNotAllowed) |
@@ -644,7 +645,6 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
644 | } | 645 | } |
645 | 646 | ||
646 | func reqlog(ctx context.Context, msg string, args ...any) { | 647 | func reqlog(ctx context.Context, msg string, args ...any) { |
647 | fmt.Fprint(os.Stderr, "[gitolfs3] ") | ||
648 | if val := ctx.Value(requestIDKey); val != nil { | 648 | if val := ctx.Value(requestIDKey); val != nil { |
649 | fmt.Fprintf(os.Stderr, "[%s] ", val.(string)) | 649 | fmt.Fprintf(os.Stderr, "[%s] ", val.(string)) |
650 | } | 650 | } |
@@ -653,7 +653,6 @@ func reqlog(ctx context.Context, msg string, args ...any) { | |||
653 | } | 653 | } |
654 | 654 | ||
655 | func log(msg string, args ...any) { | 655 | func log(msg string, args ...any) { |
656 | fmt.Fprint(os.Stderr, "[gitolfs3] ") | ||
657 | fmt.Fprintf(os.Stderr, msg, args...) | 656 | fmt.Fprintf(os.Stderr, msg, args...) |
658 | fmt.Fprint(os.Stderr, "\n") | 657 | fmt.Fprint(os.Stderr, "\n") |
659 | } | 658 | } |