Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/rest-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func (app *restServerApp) runRoot(_ *cobra.Command, _ []string) error {

// run server in background
go func() {
var err error
if !enabledTLS {
err = srv.Serve(listener)
} else {
Expand Down
2 changes: 1 addition & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func httpDefaultError(w http.ResponseWriter, code int) {
http.Error(w, http.StatusText(code), code)
}

// ServeHTTP makes this server an http.Handler. It handlers the administrative
// ServeHTTP makes this server an http.Handler. It handles the administrative
// part of the request (figuring out the filesystem location, performing
// authentication, etc) and then passes it on to repo.Handler for actual
// REST API processing.
Expand Down
3 changes: 1 addition & 2 deletions htpasswd.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (h *HtpasswdFile) expiryTimer() {
var zeros [sha256.Size]byte
// try to wipe expired cache entries
for user, entry := range h.cache {
if entry.expiry.After(now) {
if now.After(entry.expiry) {
copy(entry.verifier, zeros[:])
delete(h.cache, user)
}
Expand Down Expand Up @@ -251,7 +251,6 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
isValid := isMatchingHashAndPassword(hashedPassword, password)

if !isValid {
log.Printf("Invalid htpasswd entry for %s.", user)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (m *Manager) WrapWriter(req *http.Request, w io.Writer) (io.Writer, int, er
if contentLenStr := req.Header.Get("Content-Length"); contentLenStr != "" {
contentLen, err := strconv.ParseInt(contentLenStr, 10, 64)
if err != nil {
return nil, http.StatusLengthRequired, err
return nil, http.StatusBadRequest, err
}
if currentSize+contentLen > m.maxRepoSize {
err := fmt.Errorf("incoming blob (%d bytes) would exceed maximum size of repository (%d bytes)",
Expand Down
10 changes: 7 additions & 3 deletions repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,15 @@ func (h *Handler) saveConfig(w http.ResponseWriter, r *http.Request) {
cfg := h.getSubPath("config")

f, err := os.OpenFile(cfg, os.O_CREATE|os.O_WRONLY|os.O_EXCL, h.opt.fileMode)
if err != nil && os.IsExist(err) {
if err != nil {
if h.opt.Debug {
log.Print(err)
}
httpDefaultError(w, http.StatusForbidden)
if os.IsExist(err) {
httpDefaultError(w, http.StatusForbidden)
} else {
h.internalServerError(w, err)
}
return
}

Expand Down Expand Up @@ -807,7 +811,7 @@ func (h *Handler) internalServerError(w http.ResponseWriter, err error) {
httpDefaultError(w, http.StatusInternalServerError)
}

// internalServerError is called to report an error that occurred while
// fileAccessError is called to report an error that occurred while
// accessing a file. If the does not exist, the corresponding http status code
// will be returned to the client. All other errors are passed on to
// internalServerError
Expand Down