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
8 changes: 3 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -904,11 +904,9 @@ confirmed. A repository the upstream reports missing (404), refuses (401, 403)
or redirects is not served from the cache, also to requests that skip the ref
listing and go straight to `git-upload-pack`, until a later check succeeds.
Redirects are never followed, so point the upstream at a repository's current
location. A `git-upload-pack` request does not check the upstream itself
unless the upstream refused the repository at the last check or the copy was
last checked more than a minute past `stale_max_age` ago, so the requests of a
clone that follow its ref listing check nothing again; otherwise the
repository is checked first, as for a ref listing.
location. A `git-upload-pack` request checks the upstream only when the last
check refused the repository or the copy was last checked more than a minute
past `stale_max_age` ago, so a clone checks once, at its ref listing.

The proxy runs `git` 2.31 or newer, which must be installed (the Docker image includes it).
The `git` processes never reach the network themselves: their fetches go
Expand Down
3 changes: 1 addition & 2 deletions internal/gitcache/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ type relay struct {

type relayRoute struct {
repoURL string
// ctx ends when the fetch does, which stops its relayed requests, so a
// git helper left behind by a killed git does not keep downloading.
// ctx ends when the fetch does.
ctx context.Context
// limit caps the response bytes the route relays, 0 for no cap, and
// budget, when set, holds space within MaxSize for them. exceeded and
Expand Down
6 changes: 2 additions & 4 deletions internal/metadata/npm/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ func decodeValue(dec *jsontext.Decoder, v any) error {
return json.Unmarshal(raw, v)
}

// objectKeys reads a value and returns its keys when it is an object. The
// members' values are skipped without being kept.
// objectKeys reads a value and returns its keys when it is an object.
func objectKeys(dec *jsontext.Decoder) ([]string, bool, error) {
kind := dec.PeekKind()
if kind != '{' && kind != '[' {
Expand Down Expand Up @@ -391,8 +390,7 @@ func LookupVersion(r io.Reader, version string) (VersionEntry, error) {
}

// objectMember reads a value and returns its member key when it is an object
// that has one, the last if repeated, or nil. Other members are skipped
// without being kept.
// that has one, the last if repeated, or nil.
func objectMember(dec *jsontext.Decoder, key string) (json.RawMessage, error) {
kind := dec.PeekKind()
if kind != '{' && kind != '[' {
Expand Down
2 changes: 1 addition & 1 deletion internal/metadata/npm/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestLookupVersion(t *testing.T) {
// invalid UTF-8 in strings, and a version entry's bytes kept as they are.
func TestStreamReadsJSONAsEncodingJSON(t *testing.T) {
entry := "{ \"name\" : \"demo\",\n \"x\":1, \"x\":2, \"note\":\"caf\xe9\" }"
doc := "{\"readme\":\"bad \xff byte\",\"meta\":{\"k\":1,\"k\":2},\"dist-tags\":{\"latest\":\"1.0.0\",\"latest\":\"1.0.0\"}," +
doc := "{\"readme\":\"bad \xff byte\",\"meta\":{\"k\":1,\"k\":2},\"dist-tags\":{\"latest\":\"0.9.0\",\"latest\":\"1.0.0\"}," +
"\"versions\":{\"1.0.0\":" + entry + "},\"time\":{\"1.0.0\":\"2020-01-01T00:00:00Z\"}}\n"
if !json.Valid([]byte(strings.ToValidUTF8(doc, "?"))) {
t.Fatal("test document isn't JSON")
Expand Down
Loading