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

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

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