From 6e02c3e93095c8557c80e784dcdd3bc5c9a8ad2f Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 15 Jul 2022 00:08:33 +0800 Subject: [PATCH] =?UTF-8?q?:ambulance:=20=E4=BF=AE=E5=A4=8D=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=20Data=20=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/import.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/model/import.go b/kernel/model/import.go index e7c4c5cdd..ca94f78c7 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -311,12 +311,20 @@ func ImportData(zipPath string) (err error) { if 0 < len(files) { return errors.New("invalid data.zip") } + dirs, err := os.ReadDir(unzipPath) + if nil != err { + util.LogErrorf("check data.zip failed: %s", err) + return errors.New("check data.zip failed") + } + if 1 != len(dirs) { + return errors.New("invalid data.zip") + } writingDataLock.Lock() defer writingDataLock.Unlock() filelock.ReleaseAllFileLocks() - tmpDataPath := unzipPath + tmpDataPath := filepath.Join(unzipPath, dirs[0].Name()) if err = stableCopy(tmpDataPath, util.DataDir); nil != err { util.LogErrorf("copy data dir from [%s] to [%s] failed: %s", tmpDataPath, util.DataDir, err) err = errors.New("copy data failed")