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

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

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