fix: 模板重复导入问题

This commit is contained in:
root 2025-07-10 21:30:10 +08:00
parent 6b18e51f26
commit 9f6b6630ce
1 changed files with 11 additions and 3 deletions

View File

@ -191,9 +191,17 @@ class TemplateManager:
# Load and parse draft content # Load and parse draft content
with open(draft_file, 'r', encoding='utf-8') as f: with open(draft_file, 'r', encoding='utf-8') as f:
draft_content = json.load(f) draft_content = json.load(f)
# Generate template ID # Use the original template ID from draft_content.json
template_id = str(uuid.uuid4()) template_id = draft_content.get('id')
if not template_id:
logger.warning(f"No 'id' field found in draft_content.json for {template_path}")
return None
# Check if template already exists
if template_id in self.templates_metadata:
logger.info(f"Template {template_id} already exists, skipping import")
return None
# Create template directory # Create template directory
template_dir = self.templates_dir / template_id template_dir = self.templates_dir / template_id