{"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":236,"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":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/sync.go#L218-L254","documentation":"During SyncDataBeforeEnableEncryptedNotebook, after the cloud directory name passes validation, the kernel runs checkSync(false, false, true) to verify sync is actually possible (network reachable, auth valid, index usable). If that preflight check fails, localized message 53 is returned and enabling the encrypted notebook is blocked, since a failed sync means the cloud state cannot be guaranteed.","triggerScenarios":"EnableEncryptedNotebookWithSync is invoked with sync enabled, a valid CloudName, but checkSync fails — e.g. no network connection, invalid cloud authentication token, cloud service unreachable, or sync suspended (auto-sync in a suspended state).","commonSituations":"User is offline when trying to enable encryption; cloud subscription expired or token invalidated; SiYuan cloud endpoint unreachable; sync was suspended by a previous error and not resumed.","solutions":["Restore network connectivity / valid cloud authentication, then retry enabling the encrypted notebook.","Open the sync settings or use the manual sync button to confirm sync works before enabling encryption.","If checkSync reported suspended sync, resume sync (resumeSync) first.","If cloud sync is unwanted, disable sync before enabling the encrypted notebook."],"exampleFix":"// before\nerr := model.SyncDataBeforeEnableEncryptedNotebook()\n// after\nmodel.ResumeSync() // ensure sync is not suspended\nerr := model.SyncDataBeforeEnableEncryptedNotebook()","handlingStrategy":"try-catch","validationCode":"// Go: preflight reachability and auth before enabling\nif conf.Sync.Enabled && !syncAvailable() { /* fix network/auth first */ }","typeGuard":null,"tryCatchPattern":"if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {\n    // Language(53): sync preflight failed; check network/auth, then retry\n    return err\n}","preventionTips":["Confirm network connectivity and valid cloud authentication before enabling encryption","Resume suspended sync (resumeSync) before enabling","Perform one successful manual sync as a preflight step"],"tags":["go","sync","network","preflight-check"],"backgroundTag":"network-request-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}