{"record":{"id":"179c56db31cdc343","repo":"siyuan-note/siyuan","slug":"conf-language-53","errorCode":null,"errorMessage":"Conf.Language(53)","messagePattern":"Conf\\.Language\\(53\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/sync.go","lineNumber":232,"sourceCode":"\t}\n\treturn\n}\n\nfunc SyncData(byHand bool) {\n\tsyncData(false, byHand)\n}\n\n// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。\n// 未启用数据同步时直接返回；已启用数据同步时，任何同步失败都会阻止继续创建新的密钥体系。\nfunc SyncDataBeforeEnableEncryptedNotebook() error {\n\tif !Conf.Sync.Enabled {\n\t\treturn nil\n\t}\n\tif !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {\n\t\treturn errors.New(Conf.Language(123))\n\t}\n\tif !checkSync(false, false, true) {\n\t\treturn errors.New(Conf.Language(53))\n\t}\n\n\t// 不复用请求合并状态，确保调用返回前确实完成了一次由当前启用操作发起的完整同步。\n\tlockSync()\n\tdefer unlockSync()\n\tif err := syncDataLocked(false, true); err != nil {\n\t\tif Conf.Sync.Stat != \"\" {\n\t\t\treturn errors.New(Conf.Sync.Stat)\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc lockSync() {\n\tsyncLock.Lock()\n\tisSyncing.Store(true)\n}","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/sync.go#L214-L250","documentation":"In SyncDataBeforeEnableEncryptedNotebook, if checkSync(false, false, true) returns false, the function returns Conf.Language(53) = 'Data synchronization has not been enabled'. checkSync validates sync preconditions (enabled, provider configured, not already syncing, etc.); passing false here means the environment is not in a syncable state even though Conf.Sync.Enabled appeared true earlier in the function.","triggerScenarios":"checkSync returns false because the sync provider is not fully configured (missing S3/WebDAV/Local credentials), another sync is in flight and locked, or an internal precondition failed. Fires during the encryption-enable flow only when sync is nominally on but not actually runnable.","commonSituations":"User enabled sync in config but never completed provider setup (no S3 keys / WebDAV URL). A background sync is mid-flight and holds syncLock. Provider was switched to one whose config is incomplete.","solutions":["Complete the sync provider setup in Settings - Cloud (S3/WebDAV/Local credentials, endpoint, path).","Wait for any in-progress sync to finish, then retry enabling encryption.","If unsure, run a manual sync (Settings - Sync now) first; if that succeeds, retry the enable."],"exampleFix":"// no code change; runtime precondition\n// before: enable encryption while sync provider unconfigured -> error 53\n// after: configure provider, run Sync now, then enable encryption","handlingStrategy":"validation","validationCode":"// Go: before enabling encryption, ensure a sync will actually run\nif !checkSync(false, false, true) {\n    return errors.New(\"finish sync provider setup, then enable encryption\")\n}","typeGuard":"// Go\nfunc syncRunnable() bool { return checkSync(false, false, true) }","tryCatchPattern":null,"preventionTips":["Drive a manual successful sync before first-time encryption enable.","Validate provider credentials in Settings before flipping sync enabled.","Avoid enabling encryption during an active background sync."],"tags":["sync","crypto","encryption","cloud","i18n","kernel","precondition"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}