scripts: Synced dbgbmapd3.py Lfs class changes

- Added Lfs.traverse for full filesystem traversal
- Added Rbyd.shrub flag so we can tell if an Rbyd is a shrub
- Removed redundant leaves from paths in leaf iters
This commit is contained in:
Christopher Haster
2025-04-05 02:23:52 -05:00
parent 5f06558cbe
commit 97e2786545
5 changed files with 117 additions and 14 deletions

View File

@@ -486,6 +486,7 @@ class Ralt:
# our core rbyd type
class Rbyd:
def __init__(self, blocks, trunk, weight, rev, eoff, cksum, data, *,
shrub=False,
gcksumdelta=None,
corrupt=False):
if isinstance(blocks, int):
@@ -499,6 +500,7 @@ class Rbyd:
self.cksum = cksum
self.data = data
self.shrub = shrub
self.gcksumdelta = gcksumdelta
self.corrupt = corrupt
@@ -687,6 +689,7 @@ class Rbyd:
# this helps avoid race conditions with cksums and stuff
shrub = cls._fetch(rbyd.data, rbyd.block, trunk)
shrub.blocks = rbyd.blocks
shrub.shrub = True
return shrub
def lookupnext(self, rid, tag=None, *,
@@ -945,6 +948,10 @@ class Btree:
def cksum(self):
return self.rbyd.cksum
@property
def shrub(self):
return self.rbyd.shrub
def addr(self):
return self.rbyd.addr()
@@ -1127,7 +1134,9 @@ class Btree:
break
if path:
yield bid-rid + (rbyd.weight-1), rbyd, path_[:-1]
yield (bid-rid + (rbyd.weight-1), rbyd,
# path tail is usually redundant unless corrupt
path_[:-1] if rbyd else path_)
else:
yield bid-rid + (rbyd.weight-1), rbyd
bid += rbyd.weight - rid + 1
@@ -1892,7 +1901,9 @@ class Mtree:
else:
bid, rbyd, rid = mdir
if path:
yield (bid-rid + (rbyd.weight-1), rbyd), path_[:-1]
yield ((bid-rid + (rbyd.weight-1), rbyd),
# path tail is usually redundant unless corrupt
path_[:-1] if rbyd else path_)
else:
yield (bid-rid + (rbyd.weight-1), rbyd)
mid = self.mid(bid-rid + (rbyd.weight-1) + 1)
@@ -2107,9 +2118,10 @@ class Mtree:
else:
bid_, rbyd_, rid_, name_ = r
if bid_ is None:
return None, path_
else:
return None
if path:
return None, path_
else:
return None
# corrupt btree node?
if not rbyd_: