From 60f0d8053d22e264e900e94f16022e8c0f726a18 Mon Sep 17 00:00:00 2001 From: black1552 Date: Thu, 5 Feb 2026 10:30:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(database):=20=E4=BC=98=E5=8C=96SQLite?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9D=E5=A7=8B=E5=8C=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在创建数据库文件前先检查文件是否存在 - 避免重复创建已存在的数据库文件 - 更新项目配置文件中的文件修改时间戳 --- .idea/GOHCache.xml | 6 +++--- database/database.go | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.idea/GOHCache.xml b/.idea/GOHCache.xml index c9c824c..7aee180 100644 --- a/.idea/GOHCache.xml +++ b/.idea/GOHCache.xml @@ -201,7 +201,7 @@ - @@ -342,7 +342,7 @@ - @@ -398,7 +398,7 @@ - diff --git a/database/database.go b/database/database.go index f42db85..5ce41e7 100644 --- a/database/database.go +++ b/database/database.go @@ -68,10 +68,12 @@ func mysqlInit() { } func sqliteInit() { - _, err = gfile.Create(dns.String()) - if err != nil { - log.Error("创建数据库文件失败: ", err) - return + if !gfile.Exists(dns.String()) { + _, err = gfile.Create(dns.String()) + if err != nil { + log.Error("创建数据库文件失败: ", err) + return + } } Type = sqlite.Open(fmt.Sprintf("%s?cache=shared&mode=rwc&_busy_timeout=10000&_fk=1&_journal=WAL&_sync=FULL", dns.String())) }