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 756 B

123456789101112131415161718192021222324252627282930313233343536
  1. package ops2
  2. import (
  3. "context"
  4. "io"
  5. "gitlink.org.cn/cloudream/common/pkgs/future"
  6. "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec"
  7. "gitlink.org.cn/cloudream/common/utils/io2"
  8. )
  9. func init() {
  10. // OpUnion.AddT((*Length)(nil))
  11. }
  12. type Length struct {
  13. Input *exec.StreamVar `json:"input"`
  14. Output *exec.StreamVar `json:"output"`
  15. Length int64 `json:"length"`
  16. }
  17. func (o *Length) Execute(ctx context.Context, e *exec.Executor) error {
  18. err := e.BindVars(ctx, o.Input)
  19. if err != nil {
  20. return err
  21. }
  22. defer o.Input.Stream.Close()
  23. fut := future.NewSetVoid()
  24. o.Output.Stream = io2.AfterReadClosedOnce(io2.Length(o.Input.Stream, o.Length), func(closer io.ReadCloser) {
  25. fut.SetVoid()
  26. })
  27. e.PutVars(o.Output)
  28. return fut.Wait(ctx)
  29. }

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