fix:兼容旧图片格式

This commit is contained in:
SengokuCola
2025-06-14 20:38:30 +08:00
parent e744de2178
commit 733f76b280
2 changed files with 16 additions and 8 deletions

View File

@@ -381,13 +381,20 @@ class ImageManager:
existing_image = Images.get_or_none(Images.emoji_hash == image_hash) existing_image = Images.get_or_none(Images.emoji_hash == image_hash)
if existing_image: if existing_image:
# print(f"图片已存在: {existing_image.image_id}") # 检查是否缺少必要字段,如果缺少则创建新记录
# print(f"图片描述: {existing_image.description}") if (not hasattr(existing_image, 'image_id') or not existing_image.image_id or
# print(f"图片计数: {existing_image.count}") not hasattr(existing_image, 'count') or existing_image.count is None or
# 更新计数 not hasattr(existing_image, 'vlm_processed') or existing_image.vlm_processed is None):
existing_image.count += 1 logger.debug(f"图片记录缺少必要字段,补全旧记录: {image_hash}")
existing_image.save() image_id = str(uuid.uuid4())
return existing_image.image_id, f"[picid:{existing_image.image_id}]" else:
# print(f"图片已存在: {existing_image.image_id}")
# print(f"图片描述: {existing_image.description}")
# print(f"图片计数: {existing_image.count}")
# 更新计数
existing_image.count += 1
existing_image.save()
return existing_image.image_id, f"[picid:{existing_image.image_id}]"
else: else:
# print(f"图片不存在: {image_hash}") # print(f"图片不存在: {image_hash}")
image_id = str(uuid.uuid4()) image_id = str(uuid.uuid4())
@@ -411,6 +418,7 @@ class ImageManager:
type="image", type="image",
timestamp=current_timestamp, timestamp=current_timestamp,
vlm_processed=False, vlm_processed=False,
count=1,
) )
# 启动异步VLM处理 # 启动异步VLM处理

View File

@@ -48,7 +48,7 @@ TEMPLATE_DIR = "template"
# 考虑到实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码 # 考虑到实际上配置文件中的mai_version是不会自动更新的,所以采用硬编码
# 对该字段的更新请严格参照语义化版本规范https://semver.org/lang/zh-CN/ # 对该字段的更新请严格参照语义化版本规范https://semver.org/lang/zh-CN/
MMC_VERSION = "0.7.4-snapshot.1" MMC_VERSION = "0.8.0-snapshot.1"
def update_config(): def update_config():