diff --git a/pkg/blobserver/google/drive/service/service.go b/pkg/blobserver/google/drive/service/service.go index 45a7dcb8e..494a470ef 100644 --- a/pkg/blobserver/google/drive/service/service.go +++ b/pkg/blobserver/google/drive/service/service.go @@ -139,8 +139,7 @@ func (s *DriveService) Fetch(ctx context.Context, title string) (body io.ReadClo return } - req, _ := http.NewRequest("GET", file.DownloadUrl, nil) - req.WithContext(ctx) + req, _ := http.NewRequestWithContext(ctx, "GET", file.DownloadUrl, nil) var resp *http.Response if resp, err = s.client.Transport.RoundTrip(req); err != nil { return diff --git a/pkg/blobserver/s3/s3_test.go b/pkg/blobserver/s3/s3_test.go index f832c8b43..0d81c4896 100644 --- a/pkg/blobserver/s3/s3_test.go +++ b/pkg/blobserver/s3/s3_test.go @@ -107,6 +107,9 @@ func TestS3WriteFiles(t *testing.T) { } defer dir.Close() names, err := dir.Readdirnames(-1) + if err != nil { + t.Fatal(err) + } for _, name := range names { f, err := os.Open(filepath.Join(*flagTestData, name)) if err != nil { diff --git a/pkg/conv/conv.go b/pkg/conv/conv.go index f868a34b1..06c859521 100644 --- a/pkg/conv/conv.go +++ b/pkg/conv/conv.go @@ -42,7 +42,7 @@ func ParseFields(v []byte, dst ...interface{}) error { case *blob.Ref: br, ok := blob.ParseBytes(thisv) if !ok { - + return fmt.Errorf("invalid blobref %q", thisv) } *dv = br case *uint32: diff --git a/pkg/importer/feed/parse.go b/pkg/importer/feed/parse.go index 6a5335875..3ffa8cf5f 100644 --- a/pkg/importer/feed/parse.go +++ b/pkg/importer/feed/parse.go @@ -229,10 +229,10 @@ func atomTitle(t *atom.Text) string { if t == nil { return "" } - if t.Type == "html" { - // see: https://github.com/mjibson/goread/blob/59aec794f3ef87b36c1bac029438c33a6aa6d8d3/utils.go#L533 - //return html.UnescapeString(sanitizer.StripTags(t.Body)) - } + // if t.Type == "html" { + // see: https://github.com/mjibson/goread/blob/59aec794f3ef87b36c1bac029438c33a6aa6d8d3/utils.go#L533 + // return html.UnescapeString(sanitizer.StripTags(t.Body)) + // } return textTitle(t.Body) } diff --git a/pkg/schema/dirreader.go b/pkg/schema/dirreader.go index 9a77d0da2..8bec19077 100644 --- a/pkg/schema/dirreader.go +++ b/pkg/schema/dirreader.go @@ -21,7 +21,6 @@ import ( "encoding/json" "errors" "fmt" - "io" "go4.org/syncutil" @@ -154,7 +153,6 @@ func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEnt up = len(sts) } else { if n > (len(sts) - dr.current) { - err = io.EOF up = len(sts) } } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index a1377cfe4..65d3cca9b 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -612,9 +612,7 @@ func (bb *Builder) SetStaticSetMembers(members []blob.Ref) []*Blob { subss := ss.SetStaticSetMembers(members[i*perSubset : (i+1)*perSubset]) subsets = append(subsets, ss.Blob()) allSubsets = append(allSubsets, ss.Blob()) - for _, v := range subss { - allSubsets = append(allSubsets, v) - } + allSubsets = append(allSubsets, subss...) } // Deal with the rest (of the euclidean division) diff --git a/pkg/schema/schema_test.go b/pkg/schema/schema_test.go index ca1f15bfd..d3c859306 100644 --- a/pkg/schema/schema_test.go +++ b/pkg/schema/schema_test.go @@ -370,8 +370,7 @@ func TestAsClaimAndAsShare(t *testing.T) { bb := NewSetAttributeClaim(br, "title", "Test Title") getBlob := func() *Blob { - var c *Blob - c = bb.Blob() + c := bb.Blob() c.ss.Sig = "non-null-sig" // required by AsShare return c } @@ -420,7 +419,7 @@ func TestAsClaimAndAsShare(t *testing.T) { bb = bb.SetClaimDate(time.Now()) // Would be better to use search.SearchQuery but we can't reference it here. bb.SetShareSearch(&struct{}{}) - s, ok = getBlob().AsShare() + _, ok = getBlob().AsShare() if !ok { t.Error("Share claim failed to return share with search") } diff --git a/pkg/test/integration/upload_test.go b/pkg/test/integration/upload_test.go index 7d379af7d..5cc11f4b4 100644 --- a/pkg/test/integration/upload_test.go +++ b/pkg/test/integration/upload_test.go @@ -57,7 +57,7 @@ func TestUploadFile(t *testing.T) { testUploadFile(t, c, f, false) testUploadFile(t, c, f, true) - f.modTime.Add(time.Hour) + f.modTime = f.modTime.Add(time.Hour) testUploadFile(t, c, f, true) f.name = "baz.txt" diff --git a/pkg/test/loader.go b/pkg/test/loader.go index e132aea74..05ab321cf 100644 --- a/pkg/test/loader.go +++ b/pkg/test/loader.go @@ -25,11 +25,15 @@ import ( "perkeep.org/pkg/blobserver" ) -// NewLoader +// NewLoader returns a new Loader. func NewLoader() *Loader { return &Loader{} } +// Loader is a test implementation of blobserver.Loader. +// +// Its zero value is ready for use, but callers empirically (historically) have +// used the NewLoader constructor, despite it being kinda useless. type Loader struct { mu sync.Mutex sto map[string]blobserver.Storage