Support for saving .sy files in the single-line format https://github.com/siyuan-note/siyuan/issues/8712

This commit is contained in:
Daniel 2023-07-09 22:24:32 +08:00
parent eb65bb4ec0
commit 9eeee3965a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
13 changed files with 55 additions and 22 deletions

View file

@ -185,6 +185,7 @@ func InitConf() {
Conf.FileTree.DocCreateSavePath = strings.TrimSuffix(Conf.FileTree.DocCreateSavePath, "/")
Conf.FileTree.DocCreateSavePath = strings.TrimSpace(Conf.FileTree.DocCreateSavePath)
}
util.UseSingleLineSave = Conf.FileTree.UseSingleLineSave
util.CurrentCloudRegion = Conf.CloudRegion

View file

@ -190,12 +190,14 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
renderer := render.NewJSONRenderer(tree, luteEngine.RenderOptions)
data := renderer.Render()
buf := bytes.Buffer{}
buf.Grow(4096)
if err = json.Indent(&buf, data, "", "\t"); nil != err {
return
if !util.UseSingleLineSave {
buf := bytes.Buffer{}
buf.Grow(1024 * 1024 * 2)
if err = json.Indent(&buf, data, "", "\t"); nil != err {
return
}
data = buf.Bytes()
}
data = buf.Bytes()
if err = os.WriteFile(syPath, data, 0644); nil != err {
logging.LogErrorf("write .sy [%s] failed: %s", syPath, err)