18 lines
673 B
Python
18 lines
673 B
Python
from pathlib import Path
|
|
from PyTeX.errors import *
|
|
from .checksum import md5
|
|
from typing import Optional, List, Dict
|
|
|
|
|
|
def ensure_file_integrity(file: Path, output_file_name: str, build_info: Optional[List[Dict]] = None):
|
|
if file.exists():
|
|
if not build_info:
|
|
raise UnknownFileInBuildDirectoryError(str(file))
|
|
found = False
|
|
for info in build_info:
|
|
if info['name'] == output_file_name:
|
|
if not md5(file) == info['md5sum']:
|
|
raise ModifiedFileInBuildDirectoryError(str(file))
|
|
found = True
|
|
if not found:
|
|
raise UnknownFileInBuildDirectoryError(str(file))
|