mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🚑 修复导入 Data 路径问题
This commit is contained in:
parent
c3c4061bd4
commit
6e02c3e930
1 changed files with 9 additions and 1 deletions
|
|
@ -311,12 +311,20 @@ func ImportData(zipPath string) (err error) {
|
||||||
if 0 < len(files) {
|
if 0 < len(files) {
|
||||||
return errors.New("invalid data.zip")
|
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()
|
writingDataLock.Lock()
|
||||||
defer writingDataLock.Unlock()
|
defer writingDataLock.Unlock()
|
||||||
|
|
||||||
filelock.ReleaseAllFileLocks()
|
filelock.ReleaseAllFileLocks()
|
||||||
tmpDataPath := unzipPath
|
tmpDataPath := filepath.Join(unzipPath, dirs[0].Name())
|
||||||
if err = stableCopy(tmpDataPath, util.DataDir); nil != err {
|
if err = stableCopy(tmpDataPath, util.DataDir); nil != err {
|
||||||
util.LogErrorf("copy data dir from [%s] to [%s] failed: %s", tmpDataPath, util.DataDir, err)
|
util.LogErrorf("copy data dir from [%s] to [%s] failed: %s", tmpDataPath, util.DataDir, err)
|
||||||
err = errors.New("copy data failed")
|
err = errors.New("copy data failed")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue