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.

check_object.go 797 B

123456789101112131415161718192021222324252627282930313233343536
  1. package task
  2. import (
  3. "github.com/samber/lo"
  4. "gitlink.org.cn/cloudream/common/utils/logger"
  5. mysql "gitlink.org.cn/cloudream/db/sql"
  6. )
  7. type CheckObjectTask struct {
  8. ObjectIDs []int
  9. }
  10. func NewCheckObjectTask(objIDs []int) CheckObjectTask {
  11. return CheckObjectTask{
  12. ObjectIDs: objIDs,
  13. }
  14. }
  15. func (t *CheckObjectTask) TryMerge(other Task) bool {
  16. task, ok := other.(*CheckObjectTask)
  17. if !ok {
  18. return false
  19. }
  20. t.ObjectIDs = lo.Union(t.ObjectIDs, task.ObjectIDs)
  21. return true
  22. }
  23. func (t *CheckObjectTask) Execute(execCtx *ExecuteContext, execOpts ExecuteOption) {
  24. for _, objID := range t.ObjectIDs {
  25. err := mysql.Object.DeleteUnused(execCtx.DB.SQLCtx(), objID)
  26. if err != nil {
  27. logger.WithField("ObjectID", objID).Warnf("delete unused object failed, err: %s", err.Error())
  28. }
  29. }
  30. }

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