fix(model_resolution_picker): include file size in the override cache key

- a replacement with the same mtime but different size was served stale
This commit is contained in:
Vito Sansevero
2026-10-27 12:49:17 -07:00
parent 47e95f95c3
commit 729652facf
2 changed files with 13 additions and 2 deletions
@@ -20,7 +20,7 @@ OVERRIDE_NAME = "model_resolutions.json"
MAX_REPORTED_PROBLEMS = 3
Table = Dict[str, Any]
_CacheKey = Tuple[Path, int]
_CacheKey = Tuple[Path, int, int]
_cache: Optional[Tuple[_CacheKey, Tuple[Table, List[str]]]] = None
@@ -111,7 +111,8 @@ def current_table() -> Tuple[Table, List[str]]:
if path is None:
return SHIPPED_DATA, []
try:
key: _CacheKey = (path, path.stat().st_mtime_ns)
stat = path.stat()
key: _CacheKey = (path, stat.st_mtime_ns, stat.st_size)
except OSError:
return SHIPPED_DATA, []
if _cache is not None and _cache[0] == key:
@@ -251,3 +251,13 @@ def test_alias_default_is_normalised_to_its_label(tmp_path):
config = ModelResolutionPickerNode.INPUT_TYPES()["required"]["model"][1]
assert config["default"] == "My SDXL"
def test_same_mtime_replacement_with_different_size_is_reread(tmp_path):
path = write_override(tmp_path, {"remove": ["SD 1.5"]})
old = path.stat()
assert families.resolve_family("SD 1.5") is None
path.write_text(json.dumps({"remove": ["Anima"], "default": "SDXL"}))
os.utime(path, ns=(old.st_atime_ns, old.st_mtime_ns))
assert families.resolve_family("SD 1.5") is not None
assert families.resolve_family("Anima") is None