{"record":{"id":"90484c684ce14598","repo":"siyuan-note/siyuan","slug":"data-synchronization-has-not-been-enabled","errorCode":null,"errorMessage":"Data synchronization has not been enabled","messagePattern":"Data synchronization has not been enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/sync.go","lineNumber":240,"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 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}","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/sync.go#L222-L258","documentation":"In SyncDataBeforeEnableEncryptedNotebook, after the directory check passes it calls checkSync(false,false,true); if that returns false it returns the localized message for key 53: 'Data synchronization has not been enabled'. checkSync gates on overall sync availability (enabled flag, provider setup, workspace readiness), so this error means the mandatory pre-encryption sync could not start.","triggerScenarios":"checkSync(false,false,true) returns false during EnableEncryptedNotebookWithSync — typically because sync is disabled at the functional level (Conf.Sync enablement state), the cloud provider is unreachable/configured incompletely, or another sync holds the lock.","commonSituations":"User toggled a directory but the sync feature itself is off; concurrent sync in progress; incomplete provider credentials cause checkSync to refuse.","solutions":["Enable data synchronization fully in Settings - Sync (not just a directory) before enabling the encrypted notebook","Wait for any running sync to complete and retry","Verify provider configuration (cloud account login, S3 credentials) so checkSync passes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!window.siyuan.config.sync.enabled) {\n  alert(\"Enable data synchronization first\");\n  return;\n}","typeGuard":null,"tryCatchPattern":"if err := model.SyncDataBeforeEnableEncryptedNotebook(); err != nil {\n    // treat as feature-not-enabled; guide user to Settings - Sync\n}","preventionTips":["Fully enable data synchronization (not just directory selection) before encrypted-notebook operations","Ensure no other sync is running when invoking the API","Verify cloud provider credentials are valid so checkSync passes"],"tags":["go","sync","configuration","encrypted-notebook"],"backgroundTag":"feature-not-enabled","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"}