Remove the incorrect modifications

This commit is contained in:
2025-10-31 10:28:25 +08:00
parent b61d8aae8f
commit ae3541ca41
4 changed files with 6 additions and 115 deletions

View File

@@ -3,7 +3,6 @@ package database
import (
"fmt"
"networkDev/utils"
"path/filepath"
"sync"
"github.com/glebarez/sqlite"
@@ -92,15 +91,7 @@ func initSQLite() error {
if path == "" {
path = "./database.db"
}
// 确保数据库路径为绝对路径
absolutePath, err := utils.EnsureAbsolutePath(path)
if err != nil {
logrus.WithError(err).Error("转换SQLite数据库路径为绝对路径失败")
return err
}
dsn := fmt.Sprintf("file:%s?cache=shared&_busy_timeout=5000&_fk=1", absolutePath)
dsn := fmt.Sprintf("file:%s?cache=shared&_busy_timeout=5000&_fk=1", path)
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{})
if err != nil {
logrus.WithError(err).Error("SQLite 初始化失败")
@@ -115,9 +106,7 @@ func initSQLite() error {
}
dbInstance = db
// 记录连接成功信息(只显示文件名,不泄露完整路径)
fileName := filepath.Base(absolutePath)
logrus.WithField("file", fileName).Info("SQLite 连接已建立")
logrus.WithField("path", path).Info("SQLite 连接已建立")
return nil
}