mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Improve import conf https://github.com/siyuan-note/siyuan/issues/13718
This commit is contained in:
parent
4688ceabb8
commit
9532edcab0
1 changed files with 17 additions and 3 deletions
|
|
@ -408,12 +408,26 @@ func importConf(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "conf")
|
tmpDir := filepath.Join(importDir, "conf")
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
logging.LogErrorf("import conf failed: %s", err)
|
logging.LogErrorf("import conf failed: %s", err)
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import conf failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid conf package")
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "invalid conf package"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
entries, err := os.ReadDir(tmpDir)
|
entries, err := os.ReadDir(tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue