Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Localize Windows sync permission errors https://github.com/siyuan-note/siyuan/issues/20330

Daniel22eb17792f26
diff --git a/kernel/model/sync.go b/kernel/model/sync.go
index c1db5f5015..7997f8eef6 100644
--- a/kernel/model/sync.go
+++ b/kernel/model/sync.go
@@ -945,7 +945,7 @@ func formatRepoErrorMsg(err error) string {
msgLowerCase := strings.ToLower(msg)
if strings.Contains(msgLowerCase, "illegal byte sequence") {
msg = fmt.Sprintf(Conf.Language(397), msg)
- } else if strings.Contains(msgLowerCase, "permission denied") || strings.Contains(msg, "access is denied") {
+ } else if strings.Contains(msgLowerCase, "permission denied") || strings.Contains(msgLowerCase, "access is denied") {
msg = Conf.Language(33)
} else if strings.Contains(msgLowerCase, "region was not a valid") {
msg = Conf.language(254)
diff --git a/kernel/model/sync_error_test.go b/kernel/model/sync_error_test.go
index acd8f15435..8a73f34e99 100644
--- a/kernel/model/sync_error_test.go
+++ b/kernel/model/sync_error_test.go
@@ -79,3 +79,19 @@ func TestFormatRepoCloudLockError(t *testing.T) {
}
}
}
+
+func TestFormatRepoPermissionError(t *testing.T) {
+ previousConf, previousLangs := Conf, util.Langs
+ t.Cleanup(func() { Conf, util.Langs = previousConf, previousLangs })
+ Conf = &AppConf{Lang: "en", Sync: &conf.Sync{Provider: conf.ProviderS3}}
+ util.Langs = map[string]map[int]string{"en": {33: "check workspace permissions"}}
+ for _, message := range []string{"Access is denied.", "access is denied", "ACCESS IS DENIED", "permission denied"} {
+ t.Run(message, func(t *testing.T) {
+ err := &os.LinkError{Op: "rename", Old: "private.jpg.tmp", New: "private.jpg", Err: errors.New(message)}
+ want := "check workspace permissions (Provider: " + conf.ProviderToStr(conf.ProviderS3) + ")"
+ if got := formatRepoErrorMsg(err); got != want {
+ t.Fatalf("got %q, want %q", got, want)
+ }
+ })
+ }
+}