Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #266 from nspcc-dev/265-segfaults
Browse files Browse the repository at this point in the history
Fix segfaults
  • Loading branch information
roman-khimov authored Aug 29, 2023
2 parents 069d86e + b5c89f4 commit c4ad0d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion downloader/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, *pool.P
if n == 0 {
err = res.Close()

if errors.Is(err, io.EOF) {
if err == nil || errors.Is(err, io.EOF) {
log.Error("object not found", zap.Error(err))
response.Error(c, "object not found", fasthttp.StatusNotFound)
return
Expand Down
11 changes: 10 additions & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ var (

func TestIntegration(t *testing.T) {
versions := []dockerImage{
{image: "nspccdev/neofs-aio-testcontainer", version: "0.34.0"},
{image: "nspccdev/neofs-aio", version: "0.37.0"}, // 0.37.0 is the latest
}

Expand All @@ -84,6 +83,7 @@ func TestIntegration(t *testing.T) {
t.Run("put with duplicate keys "+image, func(t *testing.T) { putWithDuplicateKeys(t, CID) })
t.Run("simple get "+image, func(t *testing.T) { simpleGet(ctx, t, clientPool, ownerID, CID, signer) })
t.Run("get by attribute "+image, func(t *testing.T) { getByAttr(ctx, t, clientPool, ownerID, CID, signer) })
t.Run("get by attribute, not found "+image, func(t *testing.T) { getByAttrNotFound(t) })
t.Run("get zip "+image, func(t *testing.T) { getZip(ctx, t, clientPool, ownerID, CID, signer) })

cancel()
Expand Down Expand Up @@ -274,6 +274,15 @@ func getByAttr(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID
checkGetByAttrResponse(t, resp, content, expectedAttr)
}

func getByAttrNotFound(t *testing.T) {
keyAttr, valAttr := "some-attr-no", "some-get-by-attr-value-no"

resp, err := http.Get(testHost + "/get_by_attribute/" + testContainerName + "/" + keyAttr + "/" + valAttr)

require.Equal(t, http.StatusNotFound, resp.StatusCode)
require.NoError(t, err)
}

func getZip(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID user.ID, CID cid.ID, signer user.Signer) {
names := []string{"zipfolder/dir/name1.txt", "zipfolder/name2.txt"}
contents := []string{"content of file1", "content of file2"}
Expand Down

0 comments on commit c4ad0d7

Please sign in to comment.