Fix: got data from backend

This commit is contained in:
ziesorx 2025-09-13 01:00:49 +07:00
parent 42a8325faf
commit 086ba0e4d3
4 changed files with 107 additions and 12 deletions

View file

@ -251,6 +251,27 @@ class ModelManager:
if parsed.scheme in ['http', 'https']:
# Create model_id subfolder structure
model_dir = os.path.join(self.models_dir, str(model_id))
# Simple check: if model_id directory already exists, skip download entirely
if os.path.exists(model_dir) and os.path.isdir(model_dir):
dir_contents = os.listdir(model_dir)
# Filter out hidden files like .DS_Store
actual_contents = [f for f in dir_contents if not f.startswith('.')]
if actual_contents:
logger.info(f"Model {model_id} directory already exists, skipping download")
# Look for existing MPTA file
mpta_files = [f for f in actual_contents if f.endswith('.mpta')]
if mpta_files:
existing_mpta = os.path.join(model_dir, mpta_files[0])
logger.info(f"Using existing MPTA file: {existing_mpta}")
return existing_mpta
# No MPTA file but directory exists - this shouldn't happen in normal flow
# But let's handle it by proceeding with download
logger.warning(f"Model {model_id} directory exists but no MPTA file found")
# Create the directory if it doesn't exist
os.makedirs(model_dir, exist_ok=True)
# Generate cache filename
@ -260,7 +281,7 @@ class ModelManager:
cache_path = os.path.join(model_dir, filename)
# Check if already cached
# Check if exact MPTA file already cached
if os.path.exists(cache_path):
logger.info(f"Using cached model file: {cache_path}")
return cache_path