{"record":{"id":"4056a842b8804bfd","repo":"siyuan-note/siyuan","slug":"conf-language-20","errorCode":null,"errorMessage":"Conf.Language(20)","messagePattern":"Conf\\.Language\\(20\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/heading.go","lineNumber":195,"sourceCode":"\t\treturn\n\t}\n\n\tFlushTxQueue()\n\n\tsrcTree, _ := LoadTreeByBlockID(srcID)\n\tif nil == srcTree {\n\t\terr = ErrBlockNotFound\n\t\treturn\n\t}\n\tif IsBoxDoc(srcTree.Box, srcTree.ID) {\n\t\terr = errors.New(Conf.Language(341))\n\t\treturn\n\t}\n\n\tsubDir := filepath.Join(util.DataDir, srcTree.Box, strings.TrimSuffix(srcTree.Path, \".sy\"))\n\tif gulu.File.IsDir(subDir) {\n\t\tif !util.IsEmptyDir(subDir) {\n\t\t\terr = errors.New(Conf.Language(20))\n\t\t\treturn\n\t\t}\n\n\t\tif removeErr := os.Remove(subDir); nil != removeErr { // 移除空文件夹不会有副作用\n\t\t\tlogging.LogWarnf(\"remove empty dir [%s] failed: %s\", subDir, removeErr)\n\t\t}\n\t}\n\n\tif nil == treenode.GetBlockTree(targetID) {\n\t\t// 目标块不存在时忽略处理\n\t\treturn\n\t}\n\n\ttargetTree, _ := LoadTreeByBlockID(targetID)\n\tif nil == targetTree {\n\t\t// 目标块不存在时忽略处理\n\t\treturn\n\t}","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/heading.go#L177-L213","documentation":"After converting a document to headings, Doc2Heading removes the now-empty source document's directory on disk. If that directory still contains files (user assets, nested data), the removal is aborted and Conf.Language(20) — a localized 'directory is not empty' message — is returned to prevent data loss.","triggerScenarios":"Calling Doc2Heading on a source document whose corresponding data directory (data/<box>/<doc-path>/) exists and is non-empty: typically because the document has child documents or stored assets in its assets folder on disk.","commonSituations":"Converting a parent document that has sub-documents into a heading; assets saved in the doc's own directory rather than the notebook-level assets folder; leftover files from a previous failed operation.","solutions":["Move or delete the child documents and stray files inside the source document's directory, then retry Doc2Heading","Inspect the directory data/<box>/<doc-id-without-.sy>/ to find what is blocking the removal","Use the UI's document-level merge/delete (which handles child docs) instead of Doc2Heading for parents with children"],"exampleFix":"// before\nerr = model.Doc2Heading(parentDocID, targetID) // fails: dir has child docs\n// after\nif model.HasChildDocs(parentDocID) {\n    // merge or move child documents first\n    for _, child := range childDocs {\n        err = model.Doc2Heading(child.ID, targetID)\n        ...\n    }\n}\nerr = model.Doc2Heading(parentDocID, targetID)","handlingStrategy":"fallback","validationCode":"docDir := filepath.Join(model.Conf.UserDataDir ?? util.DataDir, boxID, strings.TrimSuffix(docPath, \".sy\"))\nif empty, _ := util.IsEmptyDir(docDir); !empty {\n    return fmt.Errorf(\"document directory %s still has content; clean it before Doc2Heading\", docDir)\n}","typeGuard":null,"tryCatchPattern":"if err := model.Doc2Heading(srcID, targetID); err != nil {\n    // Conf.Language(20): source directory not empty\n    // offer to move child docs/assets first, then retry\n}","preventionTips":["Convert child documents to headings (or move them) before converting a parent document","Keep assets in notebook-level assets/, not inside the document's own data directory","Check the source document for children before offering Doc2Heading in UI automation"],"tags":["heading","filesystem","directory-not-empty"],"backgroundTag":"directory-not-empty","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"}