ready to factor slightly

This commit is contained in:
Elliot Nunn 2018-10-07 22:24:57 +08:00
parent 0d09bae64e
commit 3a65952861
2 changed files with 6 additions and 4 deletions

View File

@ -106,13 +106,15 @@ class _Node:
def _mkbtree(records, bthKeyLen):
nodelist = [] # append to this as we go
index_step = 8 # pointers per index node; min=2, max=11
# pointers per index node, range 2-11
index_step = 8 # not really worth tuning
# First node is always a header node, with three records:
# header records, reserved record, bitmap record
headnode = _Node(ndType=1, ndNHeight=0, records=['header placeholder', bytes(128), 'bitmap placeholder'])
nodelist.append(headnode)
# Followed (in our implementation) by leaf nodes
bthNRecs = 0
bthRoot = 0
bthDepth = 0
@ -158,7 +160,7 @@ def _mkbtree(records, bthKeyLen):
# Add map nodes with 3952-bit bitmap recs to cover every node
bits_covered = 2048
mapnodes = []
while bits_covered < len(nodelist): # THIS ID NUMBER IS WRONG!
while bits_covered < len(nodelist):
mapnode = _Node(ndType=2, ndNHeight=1)
nodelist.append(mapnode)
mapnodes.append(mapnode)

View File

@ -22,7 +22,7 @@ def test_macos_mount():
h.drVN = b'ElmoTest'
hf = File()
hf.data = b'12345' * 10
for i in range(100):
for i in reversed(range(100)):
last = b'testfile-%03d' % i
h[last] = hf
ser = h.write(10*1024*1024)
@ -32,7 +32,7 @@ def test_macos_mount():
assert h2[b'testfile-000'].data == hf.data
open('/tmp/SMALL.dmg','wb').write(ser)
os.system('open /tmp/SMALL.dmg')
os.system('hdiutil attach /tmp/SMALL.dmg')
n = 10
while 1:
n += 1