siyuan-note/siyuan · error
template destination already exists or is inaccessible
Error message
template destination already exists or is inaccessible
What it means
Before executing a rename, the 'move' action stats the destination: the move proceeds only if root.Stat(request.Target) returns os.ErrNotExist. Any other outcome — the target already exists, or stat fails with an unrelated error (permissions, I/O) — produces this error, which conservatively refuses to clobber or proceed in doubt.
Solutions
- Choose a Target name that does not exist (verify with Action "list" first)
- If the existing destination should be replaced, delete it explicitly (Action "remove") and then move
- Fix the Target path so all parent segments are valid existing directories
- Retry after resolving filesystem/permission issues if stat failed for an environmental reason
Example fix
// before
move(TemplateFileRequest{Action: "move", Path: "a.md", Target: "b.md"})
// after
if !templateExists("b.md") { move(TemplateFileRequest{Action: "move", Path: "a.md", Target: "b.md"}) } else { /* prompt for another name */ } Defensive patterns
Strategy: validation
Validate before calling
if _, err := statTemplate(target); !errors.Is(err, os.ErrNotExist) { return errors.New("destination already exists") } Try / catch
if err != nil && strings.Contains(err.Error(), "template destination already exists") {
// prompt for a different name or delete destination explicitly
} Prevention
- Refresh the template list right before a move to detect new collisions
- Use unique names (timestamp/uuid suffix) for automated moves
- Handle case-sensitivity differences when generating target names
When it happens
Trigger: Calling ManageTemplateFiles with Action "move" where request.Target already exists in the templates root, or Stat on Target returns an error other than ErrNotExist (e.g. a component of the path is not a directory or is unreadable).
Common situations: Renaming a template to a name that another template already uses; a sync or another window created the destination between listing and moving; the target path contains an invalid segment causing stat to fail with ENOTDIR; case-only renames on case-sensitive filesystems where the target technically exists.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- skill destination already exists or is inaccessible
- 0
- attribute view custom color
- attribute view custom color
- block changed since conversion
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/300d69fea5332f81.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_manage.go:306
return nil, errors.New("cannot write a template directory")
}
err = writeTemplateSource(root, request.Path, request.Content, info == nil)
return map[string]string{"revision": fmt.Sprintf("%x", sha256.Sum256([]byte(request.Content)))}, err
case "move":
if info.IsDir() && isManagedTemplatePackage(root, request.Path) {
return nil, errors.New("template packages cannot be renamed or moved")
}
if err = checkTemplateFilePath(root, request.Target); err != nil {
return nil, err
}
if err = validateNewTemplateName(request.Target); err != nil {
return nil, err
}
if !info.IsDir() && !strings.EqualFold(path.Ext(request.Target), ".md") {
return nil, errors.New("template source must use the .md extension")
}
if _, err = root.Stat(request.Target); !errors.Is(err, os.ErrNotExist) {
return nil, errors.New("template destination already exists or is inaccessible")
}
return nil, root.Rename(request.Path, request.Target)
case "remove":
// 路径边界和版本校验完成后,直接删除选中项目及其内容。
if info.IsDir() {
return nil, root.RemoveAll(request.Path)
}
return nil, root.Remove(request.Path)
default:
return nil, errors.New("unsupported template operation")
}
}
View on GitHub (pinned to 9f775e8a12)