From 31fe8837e42d32981f79226041f3d585b4c5251a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 3 Jun 2022 16:20:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E4=BA=91?= =?UTF-8?q?=E7=AB=AF=E5=90=8C=E6=AD=A5=E7=9B=AE=E5=BD=95=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20Fix=20https://github.com/siyuan-note/siyua?= =?UTF-8?q?n/issues/5090?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/sync.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/model/sync.go b/kernel/model/sync.go index a913371e5..33e51cf2c 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -1112,6 +1112,8 @@ func CreateCloudSyncDir(name string) (err error) { syncLock.Lock() defer syncLock.Unlock() + name = strings.TrimSpace(name) + name = util.RemoveInvisible(name) if !IsValidCloudDirName(name) { return errors.New(Conf.Language(37)) } @@ -1197,7 +1199,10 @@ func formatErrorMsg(err error) string { } func IsValidCloudDirName(cloudDirName string) bool { - if 64 < len(cloudDirName) { + if "backup" == cloudDirName { + return false + } + if 16 < len(cloudDirName) { return false } From b9eaba06899c879eb5330ce8c801c28c88838139 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 3 Jun 2022 16:22:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E4=BA=91?= =?UTF-8?q?=E7=AB=AF=E5=90=8C=E6=AD=A5=E7=9B=AE=E5=BD=95=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20Fix=20https://github.com/siyuan-note/siyua?= =?UTF-8?q?n/issues/5090?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/sync.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/model/sync.go b/kernel/model/sync.go index 33e51cf2c..15339f2b0 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -30,6 +30,7 @@ import ( "strings" "sync" "time" + "unicode/utf8" "github.com/88250/gulu" "github.com/dustin/go-humanize" @@ -1202,7 +1203,8 @@ func IsValidCloudDirName(cloudDirName string) bool { if "backup" == cloudDirName { return false } - if 16 < len(cloudDirName) { + + if 16 < utf8.RuneCountInString(cloudDirName) { return false } @@ -1216,9 +1218,7 @@ func IsValidCloudDirName(cloudDirName string) bool { if strings.ContainsAny(cloudDirName, charsStr) { return false } - - tmp := util.RemoveInvisible(cloudDirName) - return tmp == cloudDirName + return true } func getSyncIgnoreList() (ret *hashset.Set) {