refactor(1): use general fast_asset_file_check helper for fast check

This commit is contained in:
bigcat88
2025-09-16 19:19:18 +03:00
parent 77332d3054
commit a336c7c165
3 changed files with 52 additions and 29 deletions

View File

@@ -0,0 +1,19 @@
import os
from typing import Optional
def fast_asset_file_check(
*,
mtime_db: Optional[int],
size_db: Optional[int],
stat_result: os.stat_result,
) -> bool:
if mtime_db is None:
return False
actual_mtime_ns = getattr(stat_result, "st_mtime_ns", int(stat_result.st_mtime * 1_000_000_000))
if int(mtime_db) != int(actual_mtime_ns):
return False
sz = int(size_db or 0)
if sz > 0:
return int(stat_result.st_size) == sz
return True