Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Shell.add, file will be closed by shell.Shell automatically #230

@treasersimplifies

Description

@treasersimplifies

I found in request.go:

func (r *Request) Send(c *http.Client) (*Response, error) {
    // snip
    if resp.StatusCode >= http.StatusBadRequest {
        // snip
        io.Copy(ioutil.Discard, resp.Body)
        resp.Body.Close()
    }
}

when developer use go-ipfs-api, they typically:

// var shells []*shell.Shell = ... connection to a lot of ipfs nodes..
localFile, err := os.Open(localfPath)
defer localFile.Close()
if err != nil {
    return nil, err
}
err = retry.Retry(func(attempt uint) error {
    response, err = shells[attempt].Add(localFile)
    if err != nil {
	return err
    }
    return nil
},
    strategy.Limit(limit),
)

So when fail on one shell.add, shell will close the file it pass, it's not good. The close of file should leave to developer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions