siyuan-note/siyuan · error
Conf.Language(20)
Error message
Conf.Language(20)
What it means
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.
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
Example fix
// before
err = model.Doc2Heading(parentDocID, targetID) // fails: dir has child docs
// after
if model.HasChildDocs(parentDocID) {
// merge or move child documents first
for _, child := range childDocs {
err = model.Doc2Heading(child.ID, targetID)
...
}
}
err = model.Doc2Heading(parentDocID, targetID) Defensive patterns
Strategy: fallback
Validate before calling
docDir := filepath.Join(model.Conf.UserDataDir ?? util.DataDir, boxID, strings.TrimSuffix(docPath, ".sy"))
if empty, _ := util.IsEmptyDir(docDir); !empty {
return fmt.Errorf("document directory %s still has content; clean it before Doc2Heading", docDir)
} Try / catch
if err := model.Doc2Heading(srcID, targetID); err != nil {
// Conf.Language(20): source directory not empty
// offer to move child docs/assets first, then retry
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 345
- access to sensitive workspace file is forbidden
- accessing assets in encrypted notebook
- ambiguous asset path
- asset must be a regular file
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/4056a842b8804bfd.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/heading.go:195
return
}
FlushTxQueue()
srcTree, _ := LoadTreeByBlockID(srcID)
if nil == srcTree {
err = ErrBlockNotFound
return
}
if IsBoxDoc(srcTree.Box, srcTree.ID) {
err = errors.New(Conf.Language(341))
return
}
subDir := filepath.Join(util.DataDir, srcTree.Box, strings.TrimSuffix(srcTree.Path, ".sy"))
if gulu.File.IsDir(subDir) {
if !util.IsEmptyDir(subDir) {
err = errors.New(Conf.Language(20))
return
}
if removeErr := os.Remove(subDir); nil != removeErr { // 移除空文件夹不会有副作用
logging.LogWarnf("remove empty dir [%s] failed: %s", subDir, removeErr)
}
}
if nil == treenode.GetBlockTree(targetID) {
// 目标块不存在时忽略处理
return
}
targetTree, _ := LoadTreeByBlockID(targetID)
if nil == targetTree {
// 目标块不存在时忽略处理
return
}View on GitHub (pinned to 9f775e8a12)