You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

length.go 841 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package ops
  2. import (
  3. "context"
  4. "io"
  5. "gitlink.org.cn/cloudream/common/pkgs/future"
  6. "gitlink.org.cn/cloudream/common/utils/io2"
  7. "gitlink.org.cn/cloudream/storage/common/pkgs/ioswitch"
  8. )
  9. type Length struct {
  10. InputID ioswitch.StreamID `json:"inputID"`
  11. OutputID ioswitch.StreamID `json:"outputID"`
  12. Length int64 `json:"length"`
  13. }
  14. func (o *Length) Execute(sw *ioswitch.Switch, planID ioswitch.PlanID) error {
  15. strs, err := sw.WaitStreams(planID, o.InputID)
  16. if err != nil {
  17. return err
  18. }
  19. defer strs[0].Stream.Close()
  20. fut := future.NewSetVoid()
  21. sw.StreamReady(planID,
  22. ioswitch.NewStream(o.OutputID,
  23. io2.AfterReadClosedOnce(io2.Length(strs[0].Stream, o.Length), func(closer io.ReadCloser) {
  24. fut.SetVoid()
  25. }),
  26. ),
  27. )
  28. fut.Wait(context.TODO())
  29. return nil
  30. }
  31. func init() {
  32. OpUnion.AddT((*Length)(nil))
  33. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。