Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:ambulance: 修复导入 Data 路径问题

Liang Ding6e02c3e93095
diff --git a/kernel/model/import.go b/kernel/model/import.go
index e7c4c5cdd4..ca94f78c78 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")