From 35f4f484242afc39fc56688c5633cd801873b69e Mon Sep 17 00:00:00 2001 From: openclaw Date: Thu, 23 Apr 2026 01:00:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(pve):=20GetAll=E8=BF=94=E5=9B=9E=E7=A9=BA?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=80=8C=E9=9D=9Enil=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E5=89=8D=E7=AB=AF=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E5=B4=A9=E6=BA=83=20[=E7=A0=9A=E7=A0=9A/K2.6?= =?UTF-8?q?=F0=9F=90=BE]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handlers/export.go | 6 +++--- server/services/pve.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/handlers/export.go b/server/handlers/export.go index 5478bd7..ad4807b 100644 --- a/server/handlers/export.go +++ b/server/handlers/export.go @@ -93,7 +93,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["machines"]; ok { - var list []models.Machine + list := []models.Machine{} if err := json.Unmarshal(raw, &list); err == nil { for _, m := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO machines (id, hostname, ip, mac, os_type, os_version, notes, ssh_port, ssh_username, ssh_password, is_online, cpu_info, memory_info, disk_info, uptime, listen_ports) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, @@ -103,7 +103,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["services"]; ok { - var list []models.Service + list := []models.Service{} if err := json.Unmarshal(raw, &list); err == nil { for _, s := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO services (id, machine_id, name, port, protocol, notes, target_machine_id, target_notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, @@ -113,7 +113,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["relationships"]; ok { - var list []models.Relationship + list := []models.Relationship{} if err := json.Unmarshal(raw, &list); err == nil { for _, r := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO relationships (id, source_machine_id, target_machine_id, relation_type, source_port, target_port, notes) VALUES (?, ?, ?, ?, ?, ?, ?)`, diff --git a/server/services/pve.go b/server/services/pve.go index b532cc7..27813f1 100644 --- a/server/services/pve.go +++ b/server/services/pve.go @@ -324,7 +324,7 @@ func (s *PVEHostService) GetAll() ([]models.PVEHost, error) { } defer rows.Close() - var hosts []models.PVEHost + hosts := []models.PVEHost{} for rows.Next() { var h models.PVEHost var verifySSL int