{"record":{"id":"69b7c96dbb7239a9","repo":"siyuan-note/siyuan","slug":"conf-language-315","errorCode":null,"errorMessage":"Conf.Language(315)","messagePattern":"Conf\\.Language\\(315\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":289,"sourceCode":"\ttmpPath := path + \".\" + gulu.Rand.String(7) + \".tmp\"\n\tif err := os.WriteFile(tmpPath, data, 0644); err != nil {\n\t\treturn err\n\t}\n\treturn os.Rename(tmpPath, path)\n}\n\n// ExportNotebookCryptoBackup 把密钥备份文件复制到 export 目录，返回可下载的相对路径。\n// 供用户主动导出保存，作为同步之外的独立恢复途径（详见设计文档 §4.1）。\n// 备份文件本身不含主密码（salt 不保密、verifier 是密文），拿到它也解不开任何数据。\nfunc ExportNotebookCryptoBackup() (downloadPath string, err error) {\n\tnotebookCryptoMu.Lock()\n\tdefer notebookCryptoMu.Unlock()\n\n\tbackupPath := dataCryptoBackupPath()\n\tdata, readErr := filelock.ReadFile(backupPath)\n\tif readErr != nil {\n\t\tif os.IsNotExist(readErr) {\n\t\t\terr = errors.New(Conf.Language(315))\n\t\t\treturn\n\t\t}\n\t\terr = readErr\n\t\treturn\n\t}\n\texportBase := filepath.Join(util.TempDir, \"export\")\n\tif mkErr := os.MkdirAll(exportBase, 0755); mkErr != nil {\n\t\terr = mkErr\n\t\treturn\n\t}\n\t// 用随机名避免不同用户/设备互相覆盖，文件名固定带易识别前缀\n\tfileName := \"notebook-crypto-backup-\" + gulu.Rand.String(7) + \".json\"\n\tdownloadPath = \"/export/\" + url.PathEscape(fileName)\n\tif writeErr := os.WriteFile(filepath.Join(exportBase, fileName), data, 0644); writeErr != nil {\n\t\terr = writeErr\n\t\treturn\n\t}\n\treturn","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/crypto.go#L271-L307","documentation":"Conf.Language(315) is the localized message telling the user that no notebook-encryption key backup file exists. ExportNotebookCryptoBackup reads <DataDir>/.siyuan/data-crypto-backup.json to produce a downloadable backup, and returns this error when that internal backup file has not been created (os.IsNotExist).","triggerScenarios":"Calling model.ExportNotebookCryptoBackup() (kernel/model/crypto.go:289) when the internal data-crypto-backup.json file does not exist — notebook encryption was never fully configured/confirmed (no backup was written at setup), or the file was manually deleted from the workspace data directory.","commonSituations":"Trying to export the key backup before ever enabling notebook encryption or completing the master-password setup that writes the backup; cleaning the workspace's hidden .siyuan directory and removing the file; migrating a workspace without the hidden file.","solutions":["First complete notebook encryption setup (set/confirm the master password in Settings - About - Notebook encryption) so the kernel writes data-crypto-backup.json, then export again","Check that <workspace>/data/.siyuan/data-crypto-backup.json exists on disk and restore it from a workspace backup if it was deleted","If encryption was never enabled, there is nothing to back up — enable encryption first if a key backup is desired"],"exampleFix":"// caller-side precheck\nconst check = await fetchSyncPost(\"/api/notebook/lsNotebooks\", {});\n// guard in UI: only enable Export backup button after crypto setup completed\nif (!window.siyuan.config.localNotebookCrypto?.enabled) { showMessage(\"Enable notebook encryption first\"); return; }\nawait fetchPost(\"/api/notebook/exportNotebookCryptoBackup\", {});","handlingStrategy":"validation","validationCode":"const crypto = window.siyuan?.config?.localNotebookCrypto;\nif (!crypto?.enabled) { showMessage(\"Notebook encryption is not configured; nothing to back up\"); return; }","typeGuard":"const hasCryptoBackup = (cfg) => !!cfg && cfg.enabled === true;","tryCatchPattern":"try {\n  const res = await fetchSyncPost(\"/api/notebook/exportNotebookCryptoBackup\", {});\n  if (res.code !== 0) showMessage(res.msg);\n} catch (e) {\n  // Language(315): internal backup file missing -> run crypto setup first\n  showMessage(\"No key backup found; complete encryption setup first\");\n}","preventionTips":["Complete encryption setup (which writes the internal backup) before offering export","Never delete the hidden <workspace>/data/.siyuan directory during cleanup","Export and store the key backup immediately after enabling encryption"],"tags":["file-not-found","encryption","backup","i18n"],"backgroundTag":"file-not-found","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"}