|
9 | 9 | from typing import Any, NamedTuple, TypeVar
|
10 | 10 |
|
11 | 11 | import pydantic
|
12 |
| -import utils |
13 | 12 | import yaml
|
14 |
| -from external.models.common import PydanticConfiguration |
15 | 13 | from PIL import Image
|
16 | 14 | from pydantic import Field
|
17 | 15 | from pydantic.networks import HttpUrl
|
18 | 16 |
|
| 17 | +import utils |
| 18 | +from external.models.common import PydanticConfiguration |
| 19 | + |
19 | 20 |
|
20 | 21 | class UrlStr(PydanticConfiguration):
|
21 | 22 | text: str
|
@@ -219,9 +220,6 @@ def _extract_offsets(_id: str, _index: int, img_path: Path, img_sources: dict[st
|
219 | 220 |
|
220 | 221 | def _get_hash_lut() -> dict[str, str]:
|
221 | 222 | """Get a lookup table for the hash of the image files content and offset if present"""
|
222 |
| - if not DEV_MODE: |
223 |
| - return {} |
224 |
| - logging.info("Since GIT_COMMIT_SHA is unset, we assume this is acting in In Dev mode.") |
225 | 223 | logging.info("Only files, with sha256(file-content)_sha256(offset) not present in the .hash_lut.json will be used")
|
226 | 224 | if HASH_LUT.is_file():
|
227 | 225 | with open(HASH_LUT, encoding="utf-8") as file:
|
@@ -268,13 +266,12 @@ def resize_and_crop() -> None:
|
268 | 266 | for img_path in IMAGE_SOURCE.glob("*.webp"):
|
269 | 267 | _id, _index = parse_image_filename(img_path.name)
|
270 | 268 | offsets = _extract_offsets(_id, _index, img_path, img_sources)
|
| 269 | + actual_hash = _gen_file_hash(img_path, offsets) |
| 270 | + if actual_hash == expected_hashes_lut.get(img_path.name, ""): |
| 271 | + continue # skip this image, since it (and its offsets) have not changed |
271 | 272 | if DEV_MODE:
|
272 |
| - actual_hash = _gen_file_hash(img_path, offsets) |
273 |
| - if actual_hash == expected_hashes_lut.get(img_path.name, ""): |
274 |
| - continue # skip this image, since it (and its offsets) have not changed |
275 | 273 | logging.debug(f"Image '{img_path.name}' has changed, resizing and cropping...")
|
276 | 274 | executor.submit(_refresh_for_all_resolutions, RefreshResolutionOrder(img_path, offsets))
|
277 |
| - if DEV_MODE: |
278 |
| - _save_hash_lut(img_sources) |
279 |
| - resize_and_crop_time = time.time() - start_time |
280 |
| - logging.info(f"Resize and crop took {resize_and_crop_time:.2f}s") |
| 275 | + _save_hash_lut(img_sources) |
| 276 | + resize_and_crop_time = time.time() - start_time |
| 277 | + logging.info(f"Resize and crop took {resize_and_crop_time:.2f}s") |
0 commit comments