From 16031c0a7e01b26054ae0b0af73e5ebe797e0cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=91=E7=90=86=E5=AD=90?= Date: Mon, 30 Dec 2024 10:23:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=E4=BC=98=E5=8C=96=20updatePropert?= =?UTF-8?q?ies=E5=87=BD=E6=95=B0=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=B8=8A=E7=BA=A7=E7=9B=AE=E5=BD=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?-=20=E5=9C=A8=E6=9B=B4=E6=96=B0=E5=B1=9E=E6=80=A7=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B9=8B=E5=89=8D=EF=BC=8C=E5=85=88=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E4=B8=8A=E7=BA=A7=E7=9B=AE=E5=BD=95=EF=BC=88=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=EF=BC=89=20-=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=9B=AE=E5=BD=95=E5=A4=B1=E8=B4=A5=E5=88=99?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=20-=20=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E9=AB=98=E4=BA=86=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E5=81=A5=E5=A3=AE=E6=80=A7=EF=BC=8C=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E5=9C=A8=E7=9B=AE=E5=BD=95=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ec/core.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ec/core.go b/ec/core.go index bc5eae4..06edb2b 100644 --- a/ec/core.go +++ b/ec/core.go @@ -9,6 +9,7 @@ import ( "io" "log" "os" + "path/filepath" "strings" "sync" ) @@ -370,6 +371,11 @@ func removeKeyFromProperties(path string, key string) error { // updateProperties 更新或添加键值对到 properties 文件 func updateProperties(path string, key string, value string) error { + // 创建上级目录 + err := os.MkdirAll(filepath.Dir(path), 0755) + if err != nil { + return fmt.Errorf("创建目录失败: %w", err) + } // 尝试打开文件,如果文件不存在则创建新文件 file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) if err != nil {