Browse Source

完成节点检查Cache的任务

gitlink
Sydonian 2 years ago
parent
commit
b84ed51ce5
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      internal/event/update_cache.go

+ 10
- 2
internal/event/update_cache.go View File

@@ -1,7 +1,7 @@
package event

import (
tskcst "gitlink.org.cn/cloudream/common/consts/event"
evtcst "gitlink.org.cn/cloudream/common/consts/event"
"gitlink.org.cn/cloudream/common/utils/logger"
mysql "gitlink.org.cn/cloudream/db/sql"
)
@@ -47,7 +47,7 @@ func (t *UpdateCache) TryMerge(other Event) bool {
func (t *UpdateCache) Execute(execCtx ExecuteContext) {
for _, entry := range t.Entries {
switch entry.Operation {
case tskcst.UPDATE_CACHE_OP_UNTEMP:
case evtcst.UPDATE_CACHE_UNTEMP:
err := mysql.Cache.DeleteTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID)

if err != nil {
@@ -55,6 +55,14 @@ func (t *UpdateCache) Execute(execCtx ExecuteContext) {
WithField("NodeID", t.NodeID).
Warnf("delete temp cache failed, err: %s", err.Error())
}

case evtcst.UPDATE_CACHE_CREATE_TEMP:
err := mysql.Cache.CreateTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID)
if err != nil {
logger.WithField("FileHash", entry.FileHash).
WithField("NodeID", t.NodeID).
Warnf("create temp cache failed, err: %s", err.Error())
}
}
}
}

Loading…
Cancel
Save