mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 16:00:51 +00:00
fix: Fix the issue of database connections not being released (#11070)
This commit is contained in:
@@ -647,11 +647,13 @@ func dropTaskLog(logDir string) {
|
||||
if err == nil {
|
||||
_ = xpackDB.Table("tampers").Where("task_id != ?", "").Select("task_id").Find(&usedTasks).Error
|
||||
}
|
||||
defer common.CloseDB(xpackDB)
|
||||
case "System":
|
||||
xpackDB, err := common.LoadDBConnByPathWithErr(path.Join(global.CONF.Base.InstallDir, "1panel/db/xpack.db"), "xpack.db")
|
||||
if err == nil {
|
||||
_ = xpackDB.Model("nodes").Where("task_id != ?", "").Select("task_id").Find(&usedTasks).Error
|
||||
}
|
||||
defer common.CloseDB(xpackDB)
|
||||
default:
|
||||
dropFileOrDir(logDir)
|
||||
_ = taskRepo.Delete(repo.WithByType(taskType))
|
||||
|
||||
@@ -259,11 +259,12 @@ func loadDbConn(snap *snapHelper, targetDir string, req dto.SnapshotCreate) erro
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
taskDB, err := common.LoadDBConnByPathWithErr(path.Join(targetDir, "db/task.db"), "core.db")
|
||||
taskDB, err := common.LoadDBConnByPathWithErr(path.Join(targetDir, "db/task.db"), "task.db")
|
||||
snap.Task.LogWithStatus(i18n.GetWithName("SnapNewDB", "task"), err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer common.CloseDB(taskDB)
|
||||
_ = taskDB.Where("id = ?", req.TaskID).Delete(&model.Task{}).Error
|
||||
}
|
||||
if !req.WithOperationLog && global.IsMaster {
|
||||
|
||||
Reference in New Issue
Block a user