| @@ -7,6 +7,7 @@ import ( | |||||
| "github.com/samber/lo" | "github.com/samber/lo" | ||||
| "gitlink.org.cn/cloudream/common/pkgs/logger" | "gitlink.org.cn/cloudream/common/pkgs/logger" | ||||
| "gitlink.org.cn/cloudream/common/utils/math2" | |||||
| "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec" | "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec" | ||||
| jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types" | jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types" | ||||
| "gorm.io/gorm" | "gorm.io/gorm" | ||||
| @@ -264,11 +265,11 @@ func (svc *UserSpaceService) DownloadPackage(req cliapi.UserSpaceDownloadPackage | |||||
| newDstSpace.RecommendHub = nil | newDstSpace.RecommendHub = nil | ||||
| } | } | ||||
| ft.AddTo(ioswitch2.NewToBaseStore(newDstSpace, dstPath)) | |||||
| ft.AddTo(ioswitch2.NewToBaseStore(newDstSpace, dstPath).WithRange(math2.NewRange(0, details[dIndex].Object.Size))) | |||||
| // 顺便保存到同存储服务的分片存储中 | // 顺便保存到同存储服务的分片存储中 | ||||
| if destSpace.UserSpace.ShardStore != nil { | if destSpace.UserSpace.ShardStore != nil { | ||||
| ft.AddTo(ioswitch2.NewToShardStore(newDstSpace, ioswitch2.RawStream(), "")) | |||||
| ft.AddTo(ioswitch2.NewToShardStore(newDstSpace, ioswitch2.RawStream(), "").WithRange(math2.NewRange(0, details[dIndex].Object.Size))) | |||||
| pinned = append(pinned, jcstypes.PinnedObject{ | pinned = append(pinned, jcstypes.PinnedObject{ | ||||
| ObjectID: details[dIndex].Object.ObjectID, | ObjectID: details[dIndex].Object.ObjectID, | ||||
| UserSpaceID: destSpace.UserSpace.UserSpaceID, | UserSpaceID: destSpace.UserSpace.UserSpaceID, | ||||
| @@ -777,7 +777,7 @@ func (t *ChangeRedundancy) ecToRep(ctx *changeRedundancyContext, obj jcstypes.Ob | |||||
| } | } | ||||
| for i := range uploadStgs { | for i := range uploadStgs { | ||||
| ft.AddTo(ioswitch2.NewToShardStoreWithRange(*uploadStgs[i].UserSpace, ioswitch2.RawStream(), fmt.Sprintf("%d", i), math2.NewRange(0, obj.Object.Size))) | |||||
| ft.AddTo(ioswitch2.NewToShardStore(*uploadStgs[i].UserSpace, ioswitch2.RawStream(), fmt.Sprintf("%d", i)).WithRange(math2.NewRange(0, obj.Object.Size))) | |||||
| } | } | ||||
| err := parser.Parse(ft, planBlder) | err := parser.Parse(ft, planBlder) | ||||
| @@ -191,13 +191,9 @@ func NewToShardStore(space jcstypes.UserSpaceDetail, strIdx StreamIndex, retStor | |||||
| } | } | ||||
| } | } | ||||
| func NewToShardStoreWithRange(space jcstypes.UserSpaceDetail, streamIndex StreamIndex, retStoreKey string, rng math2.Range) *ToShardStore { | |||||
| return &ToShardStore{ | |||||
| UserSpace: space, | |||||
| StreamIndex: streamIndex, | |||||
| ResultStoreKey: retStoreKey, | |||||
| Range: rng, | |||||
| } | |||||
| func (t *ToShardStore) WithRange(rng math2.Range) *ToShardStore { | |||||
| t.Range = rng | |||||
| return t | |||||
| } | } | ||||
| func (t *ToShardStore) GetStreamIndex() StreamIndex { | func (t *ToShardStore) GetStreamIndex() StreamIndex { | ||||
| @@ -212,6 +208,7 @@ type ToBaseStore struct { | |||||
| UserSpace jcstypes.UserSpaceDetail | UserSpace jcstypes.UserSpaceDetail | ||||
| ObjectPath jcstypes.JPath | ObjectPath jcstypes.JPath | ||||
| Option stgtypes.WriteOption | Option stgtypes.WriteOption | ||||
| Range math2.Range | |||||
| } | } | ||||
| func NewToBaseStore(space jcstypes.UserSpaceDetail, objectPath jcstypes.JPath) *ToBaseStore { | func NewToBaseStore(space jcstypes.UserSpaceDetail, objectPath jcstypes.JPath) *ToBaseStore { | ||||
| @@ -221,6 +218,11 @@ func NewToBaseStore(space jcstypes.UserSpaceDetail, objectPath jcstypes.JPath) * | |||||
| } | } | ||||
| } | } | ||||
| func (t *ToBaseStore) WithRange(rng math2.Range) *ToBaseStore { | |||||
| t.Range = rng | |||||
| return t | |||||
| } | |||||
| func (t *ToBaseStore) GetStreamIndex() StreamIndex { | func (t *ToBaseStore) GetStreamIndex() StreamIndex { | ||||
| return StreamIndex{ | return StreamIndex{ | ||||
| Type: StreamIndexRaw, | Type: StreamIndexRaw, | ||||
| @@ -228,5 +230,5 @@ func (t *ToBaseStore) GetStreamIndex() StreamIndex { | |||||
| } | } | ||||
| func (t *ToBaseStore) GetRange() math2.Range { | func (t *ToBaseStore) GetRange() math2.Range { | ||||
| return math2.Range{} | |||||
| return t.Range | |||||
| } | } | ||||