🎨 限制笔记本名和文档名最大长度为 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

@ -901,7 +901,7 @@
"103": "The update installation package has been automatically downloaded in the background. When exiting, you will be asked whether to install the new version",
"104": "The update installation package failed to download, please check the network connection",
"105": "Corrupted data repo have been automatically reset",
"106": "The maximum length of the document name is 512 characters",
"106": "Maximum length is limited to 512 characters",
"107": "Moving document [%s]",
"108": "Cleaning obsolete indexes...",
"109": "Remove reminder completed [%s]",

View file

@ -901,7 +901,7 @@
"103": "El paquete de instalación de la actualización se ha descargado automáticamente en segundo plano. Al salir, se le preguntará si desea instalar la nueva versión",
"104": "El paquete de instalación de la actualización no se pudo descargar, verifique la conexión de red",
"105": "El repositorio de datos corruptos se ha restablecido automáticamente",
"106": "La longitud máxima del nombre del documento es de 512 caracteres.",
"106": "La longitud máxima está limitada a 512 caracteres",
"107": "Moviendo documento [%s]",
"108": "Limpiando índices obsoletos...",
"109": "Eliminación de recordatorios completada [%s]",

View file

@ -901,7 +901,7 @@
"103": "Le package d'installation de la mise à jour a été automatiquement téléchargé en arrière-plan. En quittant, il vous sera demandé si vous souhaitez installer la nouvelle version",
"104": "Le package d'installation de la mise à jour n'a pas pu être téléchargé, veuillez vérifier la connexion réseau",
"105": "Le référentiel de données corrompu a été automatiquement réinitialisé",
"106": "La longueur maximale du nom du document est de 512 caractères",
"106": "La longueur maximale est limitée à 512 caractères",
"107": "Déplacement du document [%s]",
"108": "Nettoyage des index obsolètes...",
"109": "Supprimer le rappel terminé [%s]",

View file

@ -901,7 +901,7 @@
"103": "已經在後台開始自動下載更新安裝包,退出時將詢問是否安裝新版本",
"104": "更新安裝包下載失敗,請檢查網絡連接",
"105": "已經自動重置損壞的數據倉庫",
"106": "文檔名最大長度限制為 512 字符",
"106": "最大長度限制為 512 字符",
"107": "正在移動文檔 [%s]",
"108": "正在清理已過時的索引...",
"109": "移除提醒完畢 [%s]",

View file

@ -901,7 +901,7 @@
"103": "已经在后台开始自动下载更新安装包,退出时将询问是否安装新版本",
"104": "更新安装包下载失败,请检查网络连接",
"105": "已经自动重置损坏的数据仓库",
"106": "文档名最大长度限制为 512 字符",
"106": "最大长度限制为 512 字符",
"107": "正在移动文档 [%s]",
"108": "正在清理已过时的索引...",
"109": "移除提醒完毕 [%s]",

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)