mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Fix lazy hash calculation for checkpoints in extra paths
- Allow empty sha256 when hash_status is 'pending' in cache entry validator - Add on-demand hash calculation during bulk metadata refresh for checkpoints with pending hash status - Add comprehensive tests for both fixes Fixes issue where checkpoints in extra paths were not visible in UI and not processed during bulk metadata refresh due to empty sha256.
This commit is contained in:
@@ -73,6 +73,46 @@ class TestCacheEntryValidator:
|
||||
assert result.repaired is False
|
||||
assert any('sha256' in error for error in result.errors)
|
||||
|
||||
def test_validate_empty_sha256_allowed_when_hash_status_pending(self):
|
||||
"""Test validation passes when sha256 is empty but hash_status is pending (lazy hash)"""
|
||||
entry = {
|
||||
'file_path': '/models/test.safetensors',
|
||||
'sha256': '', # Empty string
|
||||
'hash_status': 'pending', # Lazy hash calculation
|
||||
}
|
||||
|
||||
result = CacheEntryValidator.validate(entry, auto_repair=False)
|
||||
|
||||
assert result.is_valid is True
|
||||
assert result.entry['sha256'] == ''
|
||||
assert result.entry['hash_status'] == 'pending'
|
||||
|
||||
def test_validate_empty_sha256_fails_when_hash_status_not_pending(self):
|
||||
"""Test validation fails when sha256 is empty and hash_status is not pending"""
|
||||
entry = {
|
||||
'file_path': '/models/test.safetensors',
|
||||
'sha256': '', # Empty string
|
||||
'hash_status': 'completed', # Not pending
|
||||
}
|
||||
|
||||
result = CacheEntryValidator.validate(entry, auto_repair=False)
|
||||
|
||||
assert result.is_valid is False
|
||||
assert any('sha256' in error for error in result.errors)
|
||||
|
||||
def test_validate_empty_sha256_fails_when_hash_status_missing(self):
|
||||
"""Test validation fails when sha256 is empty and hash_status is missing"""
|
||||
entry = {
|
||||
'file_path': '/models/test.safetensors',
|
||||
'sha256': '', # Empty string
|
||||
# hash_status missing (defaults to 'completed')
|
||||
}
|
||||
|
||||
result = CacheEntryValidator.validate(entry, auto_repair=False)
|
||||
|
||||
assert result.is_valid is False
|
||||
assert any('sha256' in error for error in result.errors)
|
||||
|
||||
def test_validate_empty_required_field_file_path(self):
|
||||
"""Test validation fails when file_path is empty string"""
|
||||
entry = {
|
||||
|
||||
Reference in New Issue
Block a user