77from prime_backup .constants import chunk_constants
88from prime_backup .db import schema
99from prime_backup .db .session import DbSession
10- from prime_backup .utils import chunk_utils , collection_utils
10+ from prime_backup .utils import chunk_utils , collection_utils , hash_utils
1111from prime_backup .utils .time_cost_stats import TimeCostStats
1212
1313
@@ -57,9 +57,9 @@ def create_chunk_groups(self, blob: schema.Blob, blob_chunks: Dict[int, schema.C
5757 needs_cut |= i == len (blob_chunks ) - 1 # last chunk group
5858 if len (current_group .chunks ) >= chunk_constants .CHUNK_GROUP_MIN_SIZE :
5959 needs_cut |= len (current_group .chunks ) >= chunk_constants .CHUNK_GROUP_MAX_SIZE # reach max size
60- needs_cut |= chunk .hash .endswith ('00 ' ) # 1/256 chance
60+ needs_cut |= chunk .hash .endswith (b' \0 ' ) # last byte is 0 -- 1/256 chance
6161 if needs_cut :
62- current_group .hash = chunk_utils .create_chunk_group_hash (chunk .hash for chunk in current_group .chunks )
62+ current_group .hash = chunk_utils .create_chunk_group_hash (hash_utils . to_hash_hex ( chunk .hash ) for chunk in current_group .chunks )
6363 raw_chunk_groups .append (current_group )
6464 chunk_group_hashes_to_chunks [current_group .hash ] = current_group .chunks
6565 current_group = _RawChunkGroup ()
@@ -77,7 +77,7 @@ def create_chunk_groups(self, blob: schema.Blob, blob_chunks: Dict[int, schema.C
7777 chunk_stored_size_sum = sum ({chunk .hash : chunk .stored_size for chunk in cg_chunks }.values ()),
7878 )
7979 known_chunk_groups [cg_hash ] = new_chunk_group
80- new_chunk_group_hashes .append (new_chunk_group .hash )
80+ new_chunk_group_hashes .append (hash_utils . to_hash_hex ( new_chunk_group .hash ) )
8181 if len (new_chunk_group_hashes ) > 0 :
8282 with self .__time_costs .measure_time_cost (CreateBackupTimeCostKey .kind_db ):
8383 self .session .flush () # creates chunk_group.id
0 commit comments