internal/pkg: compute http identifier from url
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 2m30s
Test / ShareFS (push) Successful in 3m40s
Test / Hpkg (push) Successful in 4m24s
Test / Sandbox (race detector) (push) Successful in 4m46s
Test / Hakurei (race detector) (push) Successful in 5m51s
Test / Hakurei (push) Successful in 2m28s
Test / Flake checks (push) Successful in 1m41s
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 2m30s
Test / ShareFS (push) Successful in 3m40s
Test / Hpkg (push) Successful in 4m24s
Test / Sandbox (race detector) (push) Successful in 4m46s
Test / Hakurei (race detector) (push) Successful in 5m51s
Test / Hakurei (push) Successful in 2m28s
Test / Flake checks (push) Successful in 1m41s
The previous implementation exposes arbitrary user input to the cache as an identifier, which is highly error-prone and can cause the cache to enter an inconsistent state if the user is not careful. This change replaces the implementation to compute identifier late, using url string as params. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -279,28 +279,28 @@ func TestCache(t *testing.T) {
|
||||
|
||||
cureMany(t, c, []cureStep{
|
||||
{"initial file", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
identifier,
|
||||
&testdataChecksum,
|
||||
[]byte(testdata), nil,
|
||||
), wantPathname, testdataChecksum, nil},
|
||||
|
||||
{"identical content", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
identifier0,
|
||||
&testdataChecksum,
|
||||
[]byte(testdata), nil,
|
||||
), wantPathname0, testdataChecksum, nil},
|
||||
|
||||
{"existing entry", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
identifier,
|
||||
&testdataChecksum,
|
||||
[]byte(testdata), nil,
|
||||
), wantPathname, testdataChecksum, nil},
|
||||
|
||||
{"checksum mismatch", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.ID{0xff, 0},
|
||||
new(pkg.Checksum),
|
||||
[]byte(testdata), nil,
|
||||
@@ -309,7 +309,7 @@ func TestCache(t *testing.T) {
|
||||
}},
|
||||
|
||||
{"store without validation", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.MustDecode("vsAhtPNo4waRNOASwrQwcIPTqb3SBuJOXw2G4T1mNmVZM-wrQTRllmgXqcIIoRcX"),
|
||||
nil,
|
||||
[]byte{0}, nil,
|
||||
@@ -328,14 +328,14 @@ func TestCache(t *testing.T) {
|
||||
}, nil},
|
||||
|
||||
{"error passthrough", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.ID{0xff, 1},
|
||||
nil,
|
||||
nil, stub.UniqueError(0xcafe),
|
||||
), nil, pkg.Checksum{}, stub.UniqueError(0xcafe)},
|
||||
|
||||
{"error caching", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.ID{0xff, 1},
|
||||
nil,
|
||||
nil, nil,
|
||||
@@ -357,7 +357,7 @@ func TestCache(t *testing.T) {
|
||||
}, wantPathname, testdataChecksum, nil},
|
||||
|
||||
{"cache miss checksum match", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
testdataChecksum,
|
||||
nil,
|
||||
[]byte(testdata),
|
||||
@@ -493,7 +493,7 @@ func TestCache(t *testing.T) {
|
||||
}},
|
||||
|
||||
{"cache hit bad type", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.ID{0xff, 2},
|
||||
&wantChecksum,
|
||||
[]byte(testdata), nil,
|
||||
@@ -571,7 +571,7 @@ func TestCache(t *testing.T) {
|
||||
// check cache activity while a cure is blocking
|
||||
cureMany(t, c, []cureStep{
|
||||
{"error passthrough", newStubFile(
|
||||
pkg.KindHTTP,
|
||||
pkg.KindHTTPGet,
|
||||
pkg.ID{0xff, 1},
|
||||
nil,
|
||||
nil, stub.UniqueError(0xbad),
|
||||
|
||||
Reference in New Issue
Block a user