Skip to content

Commit 499f969

Browse files
committed
Fix bug
1 parent 02d4f0f commit 499f969

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

modules/gitrepo/http.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414

1515
func serviceCmd(service string) *git.Command {
1616
switch service {
17-
case "git-receive-pack":
18-
return git.NewCommand("git-receive-pack")
19-
case "git-upload-pack":
20-
return git.NewCommand("git-upload-pack")
17+
case "receive-pack":
18+
return git.NewCommand("receive-pack")
19+
case "upload-pack":
20+
return git.NewCommand("upload-pack")
2121
default:
2222
// the service should be checked before invoking this function
2323
panic("unknown service: " + service)

routers/web/repo/githttp.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,20 @@ func (h *serviceHandler) sendFile(ctx *context.Context, contentType, file string
377377
fs := gitrepo.GetRepoFS(h.getStorageRepo())
378378
f, err := fs.Open(file)
379379
if err != nil {
380-
log.Error("Failed to open file: %v", err)
380+
if os.IsNotExist(err) {
381+
ctx.Resp.WriteHeader(http.StatusNotFound)
382+
} else {
383+
log.Error("Unable to open file %s: %v", file, err)
384+
ctx.Resp.WriteHeader(http.StatusInternalServerError)
385+
}
381386
return
382387
}
383-
defer f.Close()
384388

385389
fi, err := f.Stat()
386-
if os.IsNotExist(err) {
387-
ctx.Resp.WriteHeader(http.StatusNotFound)
390+
f.Close()
391+
if err != nil {
392+
log.Error("Unable to stat file %s: %v", file, err)
393+
ctx.Resp.WriteHeader(http.StatusInternalServerError)
388394
return
389395
}
390396

0 commit comments

Comments
 (0)