diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index f6320f9..90617a0 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -40,7 +40,7 @@ def get_health_check_args(repo_conf: repo.Config) -> List[str]: "-root=.", f"-repoSize={str(repo_conf.max_size)}", *[f"-meta={meta}" for meta in repo_conf.files.required], - get_hash(repo_conf), + f"-checkFileSumList={','.join(get_hashs(repo_conf))}", f"-checkFileNameList={','.join(repo_conf.files.immutable)}", ] @@ -97,16 +97,15 @@ def get_health_check_stage(repo_conf: repo.Config) -> result.StageDetail: def calc_sha256sum(file_path: Path) -> str: sha256_hash = hashlib.sha256() with open(file_path, "rb") as f: - for byte_block in iter(lambda: f.read(65536 * 2), b""): + for byte_block in iter(lambda: f.read(64 * 1024), b""): sha256_hash.update(byte_block) return sha256_hash.hexdigest() -def get_hash(repo_conf: repo.Config) -> str: # input should be a list +def get_hashs(repo_conf: repo.Config) -> List[str]: base_dir = (repo_conf.root / repo_conf.path).parent immutable_dir = base_dir / "immutable_files" immutable_files = [ immutable_dir / Path(file).name for file in repo_conf.files.immutable ] - immutable_hash = [calc_sha256sum(file) for file in immutable_files] - return f"-checkFileSumList={','.join(immutable_hash)}" + return [calc_sha256sum(file) for file in immutable_files]