siyuan-note/siyuan · error
errors.New(msg) with Conf.Language(7) template: remove failu
Error message
errors.New(msg) with Conf.Language(7) template: remove failure message shown to user
What it means
Box.Remove deletes a file/directory inside a notebook via filelock.Remove (called from removeDoc). On failure it formats the localized template Conf.Language(7) and returns errors.New(msg) with the OS error embedded.
Source
Thrown at kernel/model/box.go:542
fromDir := filepath.Join(boxLocalPath, oldDir)
if util.IsEmptyDir(fromDir) {
filelock.Remove(fromDir)
}
}
IncSync()
return nil
}
func (box *Box) Remove(path string) error {
if _, err := box.validateBoxPath(path); err != nil {
return err
}
boxLocalPath := filepath.Join(util.DataDir, box.ID)
filePath := filepath.Join(boxLocalPath, path)
if err := filelock.Remove(filePath); err != nil {
msg := fmt.Sprintf(Conf.Language(7), box.Name, path, err)
logging.LogErrorf("remove [path=%s] in box [%s] failed: %s", path, box.ID, err)
return errors.New(msg)
}
IncSync()
return nil
}
func (box *Box) ListFiles(path string) (ret []*FileInfo) {
// ListFiles 委托给 Ls,后者已有 validateBoxPath
fis, _, err := box.Ls(path)
if err != nil {
return
}
box.listFiles(&fis, &ret)
return
}
func (box *Box) listFiles(files, ret *[]*FileInfo) {
for _, file := range *files {
if file.isdir {View on GitHub (pinned to 8641553a1f)
Solutions
- Check the OS error text in the message for the exact cause
- Close programs holding the file (editors, previews) and retry
- Fix permissions on the file or its parent directory
- If the target is already gone, refresh the doc tree — the deletion may already be applied
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(filePath); os.IsNotExist(err) { return nil } // already deleted Try / catch
if err := box.Remove(path); err != nil { if !os.IsNotExist(cause) { showErrorToUser(err.Error()) } } Prevention
- Close editors/previews holding files before deleting
- Exclude the data dir from file lockers/indexers
- Refresh the doc tree when a delete reports a missing file
When it happens
Trigger: Deleting a document/asset when the file is already gone, locked by another process, or the process lacks delete permission on the file or its parent directory.
Common situations: Windows file lock from an indexer/antivirus or an open editor; read-only volume; doc already removed by another client; parent directory permission changes.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Remove notebook [%s] path [%s] failed: %s
- errors.New(msg) with Conf.Language(6) template: mkdir failur
- load tree failed: %s
- install local marketplace package failed: %w; rollback faile
- Query notebook failed
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/56e66e1578feb753.
Report an issue: GitHub.