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.0 kB

123456789101112131415161718192021222324252627282930313233343536
  1. package tickevent
  2. import (
  3. "gitlink.org.cn/cloudream/common/utils/logger"
  4. mysql "gitlink.org.cn/cloudream/db/sql"
  5. "gitlink.org.cn/cloudream/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. fileHashes, err := mysql.Cache.BatchGetAllFileHashes(ctx.Args.DB.SQLCtx(), e.lastCheckStart, CHECK_CACHE_BATCH_SIZE)
  16. if err != nil {
  17. logger.Warnf("batch get file hashes failed, err: %s", err.Error())
  18. return
  19. }
  20. ctx.Args.EventExecutor.Post(event.NewCheckRepCount(fileHashes))
  21. // 如果结果的长度小于预期的长度,则认为已经查询了所有,下次从头再来
  22. if len(fileHashes) < CHECK_CACHE_BATCH_SIZE {
  23. e.lastCheckStart = 0
  24. logger.Debugf("all rep count checked, next time will start check at 0")
  25. } else {
  26. e.lastCheckStart += CHECK_CACHE_BATCH_SIZE
  27. }
  28. }

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