🎨 限制笔记本名和文档名最大长度为 512 https://github.com/siyuan-note/siyuan/issues/6299

This commit is contained in:
Liang Ding 2022-10-22 17:09:59 +08:00
parent 6d2ff690b2
commit 569cd2814a
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 15 additions and 8 deletions

View file

@ -1270,7 +1270,7 @@ func RenameDoc(boxID, p, title string) (err error) {
title = gulu.Str.RemoveInvisible(title)
if 512 < utf8.RuneCountInString(title) {
// 限制文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return errors.New(Conf.Language(106))
}
@ -1391,9 +1391,8 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
func createDoc(boxID, p, title, dom string) (err error) {
title = gulu.Str.RemoveInvisible(title)
if 512 < utf8.RuneCountInString(title) {
// 限制文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return errors.New(Conf.Language(106))
}

View file

@ -24,6 +24,7 @@ import (
"runtime/debug"
"strings"
"time"
"unicode/utf8"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
@ -34,6 +35,13 @@ import (
)
func CreateBox(name string) (id string, err error) {
name = gulu.Str.RemoveInvisible(name)
if 512 < utf8.RuneCountInString(name) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
err = errors.New(Conf.Language(106))
return
}
id = ast.NewNodeID()
boxLocalPath := filepath.Join(util.DataDir, id)
err = os.MkdirAll(boxLocalPath, 0755)