Merge pull request #5177 from filecoin-project/acautman-iosize
stores: Bigger copy buffer size
This commit is contained in:
commit
65b921c62c
15
extern/sector-storage/stores/remote.go
vendored
15
extern/sector-storage/stores/remote.go
vendored
@ -3,6 +3,7 @@ package stores
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"mime"
|
"mime"
|
||||||
@ -22,12 +23,13 @@ import (
|
|||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
files "github.com/ipfs/go-ipfs-files"
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var FetchTempSubdir = "fetching"
|
var FetchTempSubdir = "fetching"
|
||||||
|
|
||||||
|
var CopyBuf = 1 << 20
|
||||||
|
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
local *Local
|
local *Local
|
||||||
index SectorIndex
|
index SectorIndex
|
||||||
@ -276,7 +278,16 @@ func (r *Remote) fetch(ctx context.Context, url, outname string) error {
|
|||||||
case "application/x-tar":
|
case "application/x-tar":
|
||||||
return tarutil.ExtractTar(resp.Body, outname)
|
return tarutil.ExtractTar(resp.Body, outname)
|
||||||
case "application/octet-stream":
|
case "application/octet-stream":
|
||||||
return files.WriteTo(files.NewReaderFile(resp.Body), outname)
|
f, err := os.Create(outname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = io.CopyBuffer(f, resp.Body, make([]byte, CopyBuf))
|
||||||
|
if err != nil {
|
||||||
|
f.Close() // nolint
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return f.Close()
|
||||||
default:
|
default:
|
||||||
return xerrors.Errorf("unknown content type: '%s'", mediatype)
|
return xerrors.Errorf("unknown content type: '%s'", mediatype)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user