Skip to content

Commit 63f1a29

Browse files
committed
Remove unnecessary code
1 parent 160539e commit 63f1a29

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

routers/web/repo/githttp.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -380,30 +380,8 @@ func (h *serviceHandler) sendFile(ctx *context.Context, contentType, file string
380380
}
381381

382382
fs := gitrepo.GetRepoFS(h.getStorageRepo())
383-
f, err := fs.Open(path.Clean(file))
384-
if err != nil {
385-
if os.IsNotExist(err) {
386-
ctx.Resp.WriteHeader(http.StatusNotFound)
387-
} else {
388-
log.Error("Unable to open file %s: %v", file, err)
389-
ctx.Resp.WriteHeader(http.StatusInternalServerError)
390-
}
391-
return
392-
}
393-
394-
fi, err := f.Stat()
395-
f.Close()
396-
if err != nil {
397-
log.Error("Unable to stat file %s: %v", file, err)
398-
ctx.Resp.WriteHeader(http.StatusInternalServerError)
399-
return
400-
}
401-
402383
ctx.Resp.Header().Set("Content-Type", contentType)
403-
ctx.Resp.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10))
404-
// http.TimeFormat required a UTC time, refer to https://pkg.go.dev/net/http#TimeFormat
405-
ctx.Resp.Header().Set("Last-Modified", fi.ModTime().UTC().Format(http.TimeFormat))
406-
http.ServeFileFS(ctx.Resp, ctx.Req, fs, file)
384+
http.ServeFileFS(ctx.Resp, ctx.Req, fs, path.Clean(file))
407385
}
408386

409387
// one or more key=value pairs separated by colons

0 commit comments

Comments
 (0)