casync: build_chunk_dict optimize for resuming (#25038)

pull/25041/head
Willem Melching 3 years ago committed by GitHub
parent 3900781092
commit 06a8ac627c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      system/hardware/tici/casync.py

@ -123,8 +123,13 @@ def parse_caibx(caibx_path: str) -> List[Chunk]:
def build_chunk_dict(chunks: List[Chunk]) -> ChunkDict: def build_chunk_dict(chunks: List[Chunk]) -> ChunkDict:
"""Turn a list of chunks into a dict for faster lookups based on hash""" """Turn a list of chunks into a dict for faster lookups based on hash.
return {c.sha: c for c in chunks} Keep first chunk since it's more likely to be already downloaded."""
r = {}
for c in chunks:
if c.sha not in r:
r[c.sha] = c
return r
def extract(target: List[Chunk], def extract(target: List[Chunk],

Loading…
Cancel
Save