{"record":{"id":"8eadcb0f47facc88","repo":"siyuan-note/siyuan","slug":"conf-sync-stat","errorCode":null,"errorMessage":"Conf.Sync.Stat","messagePattern":"Conf\\.Sync\\.Stat","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/sync.go","lineNumber":248,"sourceCode":"// SyncDataBeforeEnableEncryptedNotebook 在启用加密笔记本前执行一次完整同步。\n// 未启用数据同步时直接返回；已启用数据同步时，任何同步失败都会阻止继续创建新的密钥体系。\nfunc SyncDataBeforeEnableEncryptedNotebook() error {\n\tif !Conf.Sync.Enabled {\n\t\treturn nil\n\t}\n\tif conf.ProviderS3 != Conf.Sync.Provider && !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}\n\nfunc unlockSync() {\n\tisSyncing.Store(false)\n\tsyncLock.Unlock()\n}\n\ntype syncRequestState struct {\n\trequested atomic.Uint64","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/sync.go#L230-L266","documentation":"After the mandatory sync in SyncDataBeforeEnableEncryptedNotebook, if syncDataLocked returns an error the function surfaces Conf.Sync.Stat — the last sync status text — when non-empty, instead of the raw error. Seeing this message means a sync executed on behalf of the enable-encrypted-notebook flow failed, and the user-facing cause is stored in the sync status string.","triggerScenarios":"syncDataLocked(false,true) fails during EnableEncryptedNotebookWithSync while Conf.Sync.Stat holds a non-empty status message from the failed sync.","commonSituations":"Network failure or cloud provider error during the forced pre-enable sync; authentication token expired; remote snapshot conflict — the actual reason is in Conf.Sync.Stat/kernel logs.","solutions":["Read Conf.Sync.Stat / the sync dialog status to learn the underlying sync failure cause","Fix the root cause (network, cloud auth, provider errors) and retry enabling the encrypted notebook","Inspect kernel logs around the failed syncDataLocked call for the detailed error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// no pre-call check; failure surfaces via Conf.Sync.Stat after the sync attempt","typeGuard":null,"tryCatchPattern":"if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {\n    log.Println(\"pre-enable sync failed:\", conf.Conf.Sync.Stat, err)\n    // show Conf.Sync.Stat to the user and abort key-system creation\n}","preventionTips":["Ensure sync works end-to-end (run a manual sync) before enabling encrypted notebooks","Watch Conf.Sync.Stat after sync attempts to catch failures early","Fix network/auth issues before initiating key-system creation; a failed sync blocks it"],"tags":["go","sync","encrypted-notebook","error-propagation"],"backgroundTag":"sync-incomplete","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}