feat: Update metadata handling to use current timestamp for model modifications

This commit is contained in:
Will Miao
2025-07-22 22:04:39 +08:00
parent 0184dfd7eb
commit e04ef671e9
3 changed files with 5 additions and 74 deletions

View File

@@ -1,3 +1,4 @@
from datetime import datetime
import os
import json
import shutil
@@ -196,7 +197,7 @@ class MetadataManager:
model_name=base_name,
file_path=normalize_path(file_path),
size=os.path.getsize(real_path),
modified=os.path.getmtime(real_path),
modified=datetime.now().timestamp(),
sha256=sha256,
base_model="Unknown",
preview_url=normalize_path(preview_url),
@@ -211,7 +212,7 @@ class MetadataManager:
model_name=base_name,
file_path=normalize_path(file_path),
size=os.path.getsize(real_path),
modified=os.path.getmtime(real_path),
modified=datetime.now().timestamp(),
sha256=sha256,
base_model="Unknown",
preview_url=normalize_path(preview_url),
@@ -222,7 +223,7 @@ class MetadataManager:
)
# Try to extract model-specific metadata
await MetadataManager._enrich_metadata(metadata, real_path)
# await MetadataManager._enrich_metadata(metadata, real_path)
# Save the created metadata
await MetadataManager.save_metadata(file_path, metadata, create_backup=False)

View File

@@ -11,7 +11,7 @@ class BaseModelMetadata:
model_name: str # The model's name defined by the creator
file_path: str # Full path to the model file
size: int # File size in bytes
modified: float # Last modified timestamp
modified: float # Timestamp when the model was added to the management system
sha256: str # SHA256 hash of the file
base_model: str # Base model type (SD1.5/SD2.1/SDXL/etc.)
preview_url: str # Preview image URL
@@ -73,11 +73,6 @@ class BaseModelMetadata:
return result
@property
def modified_datetime(self) -> datetime:
"""Convert modified timestamp to datetime object"""
return datetime.fromtimestamp(self.modified)
def update_civitai_info(self, civitai_data: Dict) -> None:
"""Update Civitai information"""
self.civitai = civitai_data