mirror of
https://github.com/octoleo/syncthing.git
synced 2024-09-19 05:09:01 +00:00
cmd/stindex: Teach it about new key types
This commit is contained in:
parent
e0d4cdc9a3
commit
9cef283151
@ -80,6 +80,31 @@ func dump(ldb backend.Backend) {
|
|||||||
fmt.Printf("[deviceidx] K:%d V:%s\n", key, dev)
|
fmt.Printf("[deviceidx] K:%d V:%s\n", key, dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case db.KeyTypeIndexID:
|
||||||
|
device := binary.BigEndian.Uint32(it.Key()[1:])
|
||||||
|
folder := binary.BigEndian.Uint32(it.Key()[5:])
|
||||||
|
fmt.Printf("[indexid] D:%d F:%d I:%x\n", device, folder, it.Value())
|
||||||
|
|
||||||
|
case db.KeyTypeFolderMeta:
|
||||||
|
folder := binary.BigEndian.Uint32(it.Key()[1:])
|
||||||
|
fmt.Printf("[foldermeta] F:%d V:%x\n", folder, it.Value())
|
||||||
|
|
||||||
|
case db.KeyTypeMiscData:
|
||||||
|
fmt.Printf("[miscdata] K:%q V:%q\n", it.Key()[1:], it.Value())
|
||||||
|
|
||||||
|
case db.KeyTypeSequence:
|
||||||
|
folder := binary.BigEndian.Uint32(it.Key()[1:])
|
||||||
|
seq := binary.BigEndian.Uint64(it.Key()[5:])
|
||||||
|
fmt.Printf("[sequence] F:%d S:%d V:%q\n", folder, seq, it.Value())
|
||||||
|
|
||||||
|
case db.KeyTypeNeed:
|
||||||
|
folder := binary.BigEndian.Uint32(it.Key()[1:])
|
||||||
|
file := string(it.Key()[5:])
|
||||||
|
fmt.Printf("[need] F:%d V:%q\n", folder, file)
|
||||||
|
|
||||||
|
case db.KeyTypeBlockList:
|
||||||
|
fmt.Printf("[blocklist] H:%x\n", it.Key()[1:])
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Printf("[???]\n %x\n %x\n", it.Key(), it.Value())
|
fmt.Printf("[???]\n %x\n %x\n", it.Key(), it.Value())
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ func idxck(ldb backend.Backend) (success bool) {
|
|||||||
globals := make(map[globalKey]db.VersionList)
|
globals := make(map[globalKey]db.VersionList)
|
||||||
sequences := make(map[sequenceKey]string)
|
sequences := make(map[sequenceKey]string)
|
||||||
needs := make(map[globalKey]struct{})
|
needs := make(map[globalKey]struct{})
|
||||||
|
blocklists := make(map[string]struct{})
|
||||||
|
usedBlocklists := make(map[string]struct{})
|
||||||
var localDeviceKey uint32
|
var localDeviceKey uint32
|
||||||
success = true
|
success = true
|
||||||
|
|
||||||
@ -99,6 +101,10 @@ func idxck(ldb backend.Backend) (success bool) {
|
|||||||
folder := binary.BigEndian.Uint32(key[1:])
|
folder := binary.BigEndian.Uint32(key[1:])
|
||||||
name := nulString(key[1+4:])
|
name := nulString(key[1+4:])
|
||||||
needs[globalKey{folder, name}] = struct{}{}
|
needs[globalKey{folder, name}] = struct{}{}
|
||||||
|
|
||||||
|
case db.KeyTypeBlockList:
|
||||||
|
hash := string(key[1:])
|
||||||
|
blocklists[hash] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +143,16 @@ func idxck(ldb backend.Backend) (success bool) {
|
|||||||
success = false
|
success = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fi.BlocksHash != nil {
|
||||||
|
key := string(fi.BlocksHash)
|
||||||
|
if _, ok := blocklists[key]; !ok {
|
||||||
|
fmt.Printf("Missing block list for file %q, block list hash %x\n", fi.Name, fi.BlocksHash)
|
||||||
|
success = false
|
||||||
|
} else {
|
||||||
|
usedBlocklists[key] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for gk, vl := range globals {
|
for gk, vl := range globals {
|
||||||
@ -229,6 +245,10 @@ func idxck(ldb backend.Backend) (success bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d := len(blocklists) - len(usedBlocklists); d > 0 {
|
||||||
|
fmt.Printf("%d block list entries out of %d needs GC\n", d, len(blocklists))
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user