{"record":{"id":"f4315936f2db8e73","repo":"siyuan-note/siyuan","slug":"conf-language-377","errorCode":null,"errorMessage":"Conf.Language(377)","messagePattern":"Conf\\.Language\\(377\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/asset_download.go","lineNumber":77,"sourceCode":"\t\t\tidentity = append(identity, filepath.Clean(c.Local.Endpoint))\n\t\t}\n\t}\n\tdata, _ := json.Marshal(identity)\n\treturn fmt.Sprintf(\"%x\", sha256.Sum256(data))\n}\n\n// DeferredSyncAssets 仅读取逻辑清单，不发起下载。\nfunc DeferredSyncAssets() ([]*entity.File, error) {\n\treturn deferredSyncAssets()\n}\n\nfunc deferredSyncAssets() ([]*entity.File, error) {\n\texists, err := assetDownloadStateExists()\n\tif err != nil || !exists {\n\t\treturn nil, err\n\t}\n\tif Conf.Repo == nil || len(Conf.Repo.Key) == 0 {\n\t\treturn nil, errors.New(Conf.Language(377))\n\t}\n\treturn dejavu.ReadDeferredAssets(assetDownloadStatePath(), Conf.Repo.Key)\n}\n\n// validateAssetDownloadSourceScope 在公布新的账号身份前保留未完成的资源与历史恢复来源。\nfunc validateAssetDownloadSourceScope(scope string) error {\n\texists, err := assetDownloadStateExists()\n\tif err != nil || !exists {\n\t\treturn err\n\t}\n\tif Conf.Repo == nil || len(Conf.Repo.Key) == 0 {\n\t\treturn errors.New(Conf.Language(377))\n\t}\n\tstored, err := dejavu.ReadAssetDownloadScope(assetDownloadStatePath(), Conf.Repo.Key)\n\tif err != nil || stored == scope {\n\t\treturn err\n\t}\n\treturn requireCompleteAssetDownloads()","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/asset_download.go#L59-L95","documentation":"deferredSyncAssets reads the persisted deferred asset-download state and decrypts it with the repo key. If the data repo is not open (Conf.Repo is nil or has no key), it cannot decrypt the state and returns localized message 377: \"Please switch to Download all before changing or resetting the data repository\". Callers surface it wherever deferred assets must be reconciled.","triggerScenarios":"Any caller (DeferredSyncAssets, EnsureAssetLocal, EnsureAssetPrefixLocal, ensureAllSyncAssets, requireCompleteAssetDownloads) running while a deferred-download state file exists but the data repo is closed — i.e. no cloud repo key because the user logged out, reset the data repo, or never initialized sync while a pending asset-download state remains.","commonSituations":"Resetting or switching the data repository while deferred asset downloads are pending; fresh workspace restore with asset-download state but no repo key; closing the cloud repo (closing the padlock) without completing pending downloads.","solutions":["Initialize/open the data repo (enter the repo key via the cloud sync dialog) so Conf.Repo.Key is set, then retry","Switch the sync asset download mode to \"Download all\" and let pending downloads complete before changing or resetting the repo","Remove the deferred asset-download state file in the workspace temp dir only if you accept losing the pending-download bookkeeping","Log into the cloud account and reopen sync before resetting the data repository"],"exampleFix":"// before: repo closed while deferred state exists\ncurl -X POST http://127.0.0.1:6806/api/sync/performSync // fails with 377\n// after: open the repo first\ncurl -X POST http://127.0.0.1:6806/api/repo/initRepoKeyFromCloud\ncurl -X POST http://127.0.0.1:6806/api/sync/performSync","handlingStrategy":"try-catch","validationCode":"const sync = await fetchPost('/api/sync/getSyncInfo');\nconst repoReady = sync.data && sync.data.cloudName; // repo key initialized\nif (!repoReady) throw new Error('Open the data repo before syncing deferred assets');","typeGuard":null,"tryCatchPattern":"try { await ensureAssetLocal(...); } catch (e) { if (String(e).includes(Conf.Language ? Conf.Language(377) : 'Download all')) { await openRepoKey(); return ensureAssetLocal(...); } throw e; }","preventionTips":["Always initialize the repo key before operations that touch deferred asset state","Complete \"Download all\" pending downloads before resetting or switching the data repo","Avoid deleting workspace state files while downloads are pending","Re-login to cloud sync after restoring a workspace from backup"],"tags":["sync","assets","repo-key","state"],"backgroundTag":"missing-credentials","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}