|
@@ -55,22 +55,6 @@ type BlockTree struct {
|
|
Type string // 类型
|
|
Type string // 类型
|
|
}
|
|
}
|
|
|
|
|
|
-func GetRootUpdated() (ret map[string]string) {
|
|
|
|
- ret = map[string]string{}
|
|
|
|
- blockTrees.Range(func(key, value interface{}) bool {
|
|
|
|
- slice := value.(*btSlice)
|
|
|
|
- slice.m.Lock()
|
|
|
|
- for _, b := range slice.data {
|
|
|
|
- if b.RootID == b.ID {
|
|
|
|
- ret[b.RootID] = b.Updated
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- slice.m.Unlock()
|
|
|
|
- return true
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetBlockTreeByPath(path string) (ret *BlockTree) {
|
|
func GetBlockTreeByPath(path string) (ret *BlockTree) {
|
|
blockTrees.Range(func(key, value interface{}) bool {
|
|
blockTrees.Range(func(key, value interface{}) bool {
|
|
slice := value.(*btSlice)
|
|
slice := value.(*btSlice)
|
|
@@ -113,62 +97,6 @@ func CountBlocks() (ret int) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetRedundantPaths(boxID string, paths []string) (ret []string) {
|
|
|
|
- pathsMap := map[string]bool{}
|
|
|
|
- for _, path := range paths {
|
|
|
|
- pathsMap[path] = true
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- btPathsMap := map[string]bool{}
|
|
|
|
- blockTrees.Range(func(key, value interface{}) bool {
|
|
|
|
- slice := value.(*btSlice)
|
|
|
|
- slice.m.Lock()
|
|
|
|
- for _, b := range slice.data {
|
|
|
|
- if b.BoxID == boxID {
|
|
|
|
- btPathsMap[b.Path] = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- slice.m.Unlock()
|
|
|
|
- return true
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- for p, _ := range btPathsMap {
|
|
|
|
- if !pathsMap[p] {
|
|
|
|
- ret = append(ret, p)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ret = gulu.Str.RemoveDuplicatedElem(ret)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func GetNotExistPaths(boxID string, paths []string) (ret []string) {
|
|
|
|
- pathsMap := map[string]bool{}
|
|
|
|
- for _, path := range paths {
|
|
|
|
- pathsMap[path] = true
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- btPathsMap := map[string]bool{}
|
|
|
|
- blockTrees.Range(func(key, value interface{}) bool {
|
|
|
|
- slice := value.(*btSlice)
|
|
|
|
- slice.m.Lock()
|
|
|
|
- for _, b := range slice.data {
|
|
|
|
- if b.BoxID == boxID {
|
|
|
|
- btPathsMap[b.Path] = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- slice.m.Unlock()
|
|
|
|
- return true
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- for p, _ := range pathsMap {
|
|
|
|
- if !btPathsMap[p] {
|
|
|
|
- ret = append(ret, p)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ret = gulu.Str.RemoveDuplicatedElem(ret)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetBlockTreeRootByPath(boxID, path string) (ret *BlockTree) {
|
|
func GetBlockTreeRootByPath(boxID, path string) (ret *BlockTree) {
|
|
blockTrees.Range(func(key, value interface{}) bool {
|
|
blockTrees.Range(func(key, value interface{}) bool {
|
|
slice := value.(*btSlice)
|
|
slice := value.(*btSlice)
|
|
@@ -269,21 +197,6 @@ func RemoveBlockTreesByRootID(rootID string) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func RemoveBlockTreesByPath(boxID, path string) {
|
|
|
|
- blockTrees.Range(func(key, value interface{}) bool {
|
|
|
|
- slice := value.(*btSlice)
|
|
|
|
- slice.m.Lock()
|
|
|
|
- for _, b := range slice.data {
|
|
|
|
- if b.Path == path && b.BoxID == boxID {
|
|
|
|
- delete(slice.data, b.ID)
|
|
|
|
- slice.changed = time.Now()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- slice.m.Unlock()
|
|
|
|
- return true
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
|
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
|
|
var ids []string
|
|
var ids []string
|
|
blockTrees.Range(func(key, value interface{}) bool {
|
|
blockTrees.Range(func(key, value interface{}) bool {
|