JCS-pub/client/internal/spacesyncer/execute.go

39 lines
898 B
Go

package spacesyncer
import (
"gitlink.org.cn/cloudream/common/pkgs/trie"
stgtypes "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/types"
jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
)
func execute(syncer *SpaceSyncer, task *task) {
switch mode := task.Task.Mode.(type) {
case *jcstypes.SpaceSyncModeFull:
executeFull(syncer, task)
case *jcstypes.SpaceSyncModeDiff:
executeDiff(syncer, task, mode)
}
}
func createDirNode(tree *trie.Trie[*stgtypes.DirEntry], pathComps []string, e *stgtypes.DirEntry) {
var ptr = &tree.Root
for _, c := range pathComps {
ptr.Value = nil
ptr = ptr.Create(c)
}
ptr.Value = e
}
func removeDirNode(tree *trie.Trie[*stgtypes.DirEntry], pathComps []string) {
var ptr = &tree.Root
for _, c := range pathComps {
ptr.Value = nil
next := ptr.WalkNext(c)
if next == nil {
break
}
}
ptr.Value = nil
ptr.RemoveSelf(true)
}