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.

cache.go 1.1 kB

7 months ago
7 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package cmdline
  2. /*
  3. import (
  4. "fmt"
  5. "time"
  6. cdssdk "gitlink.org.cn/cloudream/jcs-pub/client/types"
  7. )
  8. func CacheMovePackage(ctx CommandContext, packageID cdssdk.PackageID, stgID cdssdk.StorageID) error {
  9. startTime := time.Now()
  10. defer func() {
  11. fmt.Printf("%v\n", time.Since(startTime).Seconds())
  12. }()
  13. hubID, taskID, err := ctx.Cmdline.Svc.CacheSvc().StartCacheMovePackage(1, packageID, stgID)
  14. if err != nil {
  15. return fmt.Errorf("start cache moving package: %w", err)
  16. }
  17. for {
  18. complete, err := ctx.Cmdline.Svc.CacheSvc().WaitCacheMovePackage(hubID, taskID, time.Second*10)
  19. if complete {
  20. if err != nil {
  21. return fmt.Errorf("moving complete with: %w", err)
  22. }
  23. return nil
  24. }
  25. if err != nil {
  26. return fmt.Errorf("wait moving: %w", err)
  27. }
  28. }
  29. }
  30. func CacheRemovePackage(ctx CommandContext, packageID cdssdk.PackageID, stgID cdssdk.StorageID) error {
  31. return ctx.Cmdline.Svc.CacheSvc().CacheRemovePackage(packageID, stgID)
  32. }
  33. func init() {
  34. commands.Add(CacheMovePackage, "cache", "move")
  35. commands.Add(CacheRemovePackage, "cache", "remove")
  36. }
  37. */

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