🚑 修复导入 Data 路径问题

This commit is contained in:
Liang Ding 2022-07-15 00:08:33 +08:00
parent c3c4061bd4
commit 6e02c3e930
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -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")