@@ -38,42 +38,11 @@ def get_chunks(fname, sparse, header_size):
3838 with open (fname , "rb" ) as fd :
3939 return cf (chunker .chunkify (fd ))
4040
41+ # this only works if sparse map blocks are same size as fixed chunker blocks
4142 fn = str (tmpdir / fname )
4243 make_sparsefile (fn , sparse_map , header_size = header_size )
4344 expected_content = make_content (sparse_map , header_size = header_size )
44-
45- # ChunkerFixed splits everything into fixed-size chunks (except maybe the header)
46- # We need to split the expected content similarly.
47- expected = []
48-
49- # Handle header if present (it's the first item if header_size > 0)
50- if header_size > 0 :
51- header = expected_content .pop (0 )
52- expected .append (header )
53-
54- # Flatten the rest and split into 4096 chunks
55- current_chunk_size = 4096
56- for item in expected_content :
57- if isinstance (item , int ):
58- # Hole
59- count = item
60- while count > 0 :
61- size = min (count , current_chunk_size )
62- expected .append (size )
63- count -= size
64- else :
65- # Data
66- data = item
67- while len (data ) > 0 :
68- size = min (len (data ), current_chunk_size )
69- expected .append (data [:size ])
70- data = data [size :]
71-
72- if not sparse :
73- # if the chunker is not sparse-aware, it will read holes as zeros
74- expected = [b"\0 " * x if isinstance (x , int ) else x for x in expected ]
75-
76- assert get_chunks (fn , sparse = sparse , header_size = header_size ) == expected
45+ assert get_chunks (fn , sparse = sparse , header_size = header_size ) == expected_content
7746
7847
7948@pytest .mark .skipif ("BORG_TESTS_SLOW" not in os .environ , reason = "slow tests not enabled, use BORG_TESTS_SLOW=1" )
0 commit comments