This commit is contained in:
Daniel 2025-08-21 12:01:12 +08:00
parent 6270d55fa3
commit c7c7bdb950
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 58 additions and 120 deletions

View file

@ -55,50 +55,3 @@ func GetMirrorAttrViewBlockIDs(avID string) (ret []string) {
}
return
}
type AvBlock struct {
AvID string
BlockIDs []string
}
func BatchGetMirrorAttrViewBlocks(avIDs []string) (ret []*AvBlock) {
av.AttributeViewBlocksLock.Lock()
defer av.AttributeViewBlocksLock.Unlock()
ret = []*AvBlock{}
blocks := filepath.Join(util.DataDir, "storage", "av", "blocks.msgpack")
if !filelock.IsExist(blocks) {
return
}
data, err := filelock.ReadFile(blocks)
if err != nil {
logging.LogErrorf("read attribute view blocks failed: %s", err)
return
}
avBlocks := map[string][]string{}
if err = msgpack.Unmarshal(data, &avBlocks); err != nil {
logging.LogErrorf("unmarshal attribute view blocks failed: %s", err)
return
}
for _, avID := range avIDs {
var blockIDs []string
bts := GetBlockTrees(avBlocks[avID])
for blockID := range bts {
blockIDs = append(blockIDs, blockID)
}
if 1 > len(blockIDs) {
continue
}
avBlock := &AvBlock{
AvID: avID,
BlockIDs: blockIDs,
}
ret = append(ret, avBlock)
}
return
}