mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +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,10 +408,24 @@ func importConf(c *gin.Context) {
|
|||
}
|
||||
|
||||
tmpDir := filepath.Join(importDir, "conf")
|
||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||
logging.LogErrorf("import conf failed: %s", err)
|
||||
os.RemoveAll(tmpDir)
|
||||
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||
logging.LogErrorf("import conf failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
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 = err.Error()
|
||||
ret.Msg = "invalid conf package"
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue