From f8772954f5d5704159b49d22761617e8102e0f48 Mon Sep 17 00:00:00 2001 From: zhangsan <646228430@qq.com> Date: Sat, 22 Mar 2025 11:58:16 +0800 Subject: [PATCH] =?UTF-8?q?3.22=20=E6=9B=B4=E6=96=B0=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=9C=89bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typecho_markdown_upload/typecho_direct_mysql_publisher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/typecho_markdown_upload/typecho_direct_mysql_publisher.py b/typecho_markdown_upload/typecho_direct_mysql_publisher.py index 66985d3..c364ed4 100644 --- a/typecho_markdown_upload/typecho_direct_mysql_publisher.py +++ b/typecho_markdown_upload/typecho_direct_mysql_publisher.py @@ -77,6 +77,9 @@ class TypechoDirectMysqlPublisher: ) cursor.execute(update_category_count_sql) + def normalize_content(content): + return content.replace('\r\n', '\n').replace('\r', '\n').strip() + def publish_post(self, title, content, category): """ 如果 (category, title) 已存在,则对比旧内容与新内容: @@ -112,7 +115,7 @@ class TypechoDirectMysqlPublisher: cid = exist_row[0] old_content = exist_row[1] or "" - if old_content.strip() == content_with_mark.strip(): + if self.normalize_content(old_content) == self.normalize_content(content_with_mark): # 内容相同,不更新 print(f"[INFO] 文章已存在且内容未修改: title={title}, cid={cid}, category={category},跳过更新。") return cid