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.

batch_check_all_rep_count.go 1.1 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package tickevent
  2. /*
  3. import (
  4. "gitlink.org.cn/cloudream/common/pkgs/logger"
  5. "gitlink.org.cn/cloudream/storage/scanner/internal/event"
  6. )
  7. const CHECK_CACHE_BATCH_SIZE = 100
  8. type BatchCheckAllRepCount struct {
  9. lastCheckStart int
  10. }
  11. func NewBatchCheckAllRepCount() *BatchCheckAllRepCount {
  12. return &BatchCheckAllRepCount{}
  13. }
  14. func (e *BatchCheckAllRepCount) Execute(ctx ExecuteContext) {
  15. log := logger.WithType[BatchCheckAllRepCount]("TickEvent")
  16. log.Debugf("begin")
  17. defer log.Debugf("end")
  18. fileHashes, err := ctx.Args.DB.Cache().BatchGetAllFileHashes(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_CACHE_BATCH_SIZE)
  19. if err != nil {
  20. log.Warnf("batch get file hashes failed, err: %s", err.Error())
  21. return
  22. }
  23. ctx.Args.EventExecutor.Post(event.NewCheckRepCount(fileHashes))
  24. // 如果结果的长度小于预期的长度,则认为已经查询了所有,下次从头再来
  25. if len(fileHashes) < CHECK_CACHE_BATCH_SIZE {
  26. e.lastCheckStart = 0
  27. log.Debugf("all rep count checked, next time will start check at 0")
  28. } else {
  29. e.lastCheckStart += CHECK_CACHE_BATCH_SIZE
  30. }
  31. }
  32. */

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