Browse Source

update upload/download opt

master
jojoliang 4 years ago
parent
commit
5576819d1e
  1. 13
      object.go
  2. 2
      object_test.go

13
object.go

@ -607,7 +607,7 @@ type MultiUploadOptions struct {
PartSize int64 PartSize int64
ThreadPoolSize int ThreadPoolSize int
CheckPoint bool CheckPoint bool
EnableVerification bool DisableChecksum bool
} }
type MultiDownloadOptions struct { type MultiDownloadOptions struct {
@ -616,6 +616,7 @@ type MultiDownloadOptions struct {
ThreadPoolSize int ThreadPoolSize int
CheckPoint bool CheckPoint bool
CheckPointFile string CheckPointFile string
DisableChecksum bool
} }
type MultiDownloadCPInfo struct { type MultiDownloadCPInfo struct {
@ -943,7 +944,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
return nil, nil, err return nil, nil, err
} }
// 校验 // 校验
if s.client.Conf.EnableCRC { if s.client.Conf.EnableCRC && !opt.DisableChecksum {
fd, err := os.Open(filepath) fd, err := os.Open(filepath)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -972,7 +973,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
Key: name, Key: name,
ETag: rsp.Header.Get("ETag"), ETag: rsp.Header.Get("ETag"),
} }
if rsp != nil && s.client.Conf.EnableCRC { if rsp != nil && s.client.Conf.EnableCRC && !opt.DisableChecksum {
scoscrc := rsp.Header.Get("x-cos-hash-crc64ecma") scoscrc := rsp.Header.Get("x-cos-hash-crc64ecma")
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64) icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
if icoscrc != localcrc { if icoscrc != localcrc {
@ -1105,7 +1106,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
return v, resp, err return v, resp, err
} }
if resp != nil && s.client.Conf.EnableCRC { if resp != nil && s.client.Conf.EnableCRC && !opt.DisableChecksum {
scoscrc := resp.Header.Get("x-cos-hash-crc64ecma") scoscrc := resp.Header.Get("x-cos-hash-crc64ecma")
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64) icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
if icoscrc != localcrc { if icoscrc != localcrc {
@ -1225,7 +1226,7 @@ func (s *ObjectService) Download(ctx context.Context, name string, filepath stri
if err != nil { if err != nil {
return rsp, err return rsp, err
} }
if coscrc != "" && s.client.Conf.EnableCRC { if coscrc != "" && s.client.Conf.EnableCRC && !opt.DisableChecksum {
icoscrc, _ := strconv.ParseUint(coscrc, 10, 64) icoscrc, _ := strconv.ParseUint(coscrc, 10, 64)
fd, err := os.Open(filepath) fd, err := os.Open(filepath)
if err != nil { if err != nil {
@ -1344,7 +1345,7 @@ func (s *ObjectService) Download(ctx context.Context, name string, filepath stri
if opt.CheckPoint { if opt.CheckPoint {
os.Remove(cpfile) os.Remove(cpfile)
} }
if coscrc != "" && s.client.Conf.EnableCRC { if coscrc != "" && s.client.Conf.EnableCRC && !opt.DisableChecksum {
icoscrc, _ := strconv.ParseUint(coscrc, 10, 64) icoscrc, _ := strconv.ParseUint(coscrc, 10, 64)
fd, err := os.Open(filepath) fd, err := os.Open(filepath)
if err != nil { if err != nil {

2
object_test.go

@ -796,7 +796,7 @@ func TestObjectService_Download(t *testing.T) {
} }
defer os.Remove(filePath) defer os.Remove(filePath)
// 源文件内容 // 源文件内容
totalBytes := int64(1024*1024 + 1230) //1024*1024*9 + 123) totalBytes := int64(1024*1024*9 + 1230)
b := make([]byte, totalBytes) b := make([]byte, totalBytes)
_, err = rand.Read(b) _, err = rand.Read(b)
newfile.Write(b) newfile.Write(b)

|||||||
100:0
Loading…
Cancel
Save