{"record":{"id":"034aab3e306ae38d","repo":"siyuan-note/siyuan","slug":"write-data-s-failed-s","errorCode":null,"errorMessage":"write data [%s] failed: %s","messagePattern":"write data \\[(.+?)\\] failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/filesys/tree.go","lineNumber":514,"sourceCode":"\t\t}\n\t}\n\n\tif util.ExceedLargeFileWarningSize(len(data)) {\n\t\tmsg := fmt.Sprintf(util.Langs[util.Lang][268], tree.Root.IALAttr(\"title\")+\" \"+filepath.Base(filePath), util.LargeFileWarningSize)\n\t\tutil.PushErrMsg(msg, 7000)\n\t}\n\n\tcache.SetTreeDataInBox(tree.ID, tree.Box, data)\n\tafterWriteTree(tree)\n\tsize = uint64(len(data))\n\treturn\n}\n\nfunc writeTreeByWriteFile(filePath string, data []byte) (err error) {\n\tif err = filelock.WriteFile(filePath, data); err != nil {\n\t\tmsg := fmt.Sprintf(\"write data [%s] failed: %s\", filePath, err)\n\t\tlogging.LogErrorf(\"%s\", msg)\n\t\terr = errors.New(msg)\n\t\treturn\n\t}\n\treturn\n}\n\nfunc prepareWriteTree(tree *parse.Tree) (data []byte, filePath string, err error) {\n\tif err = treenode.SyncTableCellRichInlineChanges(tree.Root); nil != err {\n\t\treturn\n\t}\n\tif err = treenode.CheckSpec(tree); nil != err {\n\t\treturn\n\t}\n\tluteEngine := util.NewLute() // 不关注用户的自定义解析渲染选项\n\n\tif nil == tree.Root.FirstChild {\n\t\tnewP := treenode.NewParagraph(\"\")\n\t\ttree.Root.AppendChild(newP)\n\t\ttree.Root.SetIALAttr(\"updated\", util.TimeFromID(newP.ID))","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/filesys/tree.go#L496-L532","documentation":"writeTreeByWriteFile persists a parsed document tree as a .sy file via filelock.WriteFile. When the underlying write fails (disk full, permission error, locked file, I/O error), it wraps the path and cause into this message, logs it, and returns a fresh error to the caller of WriteTree.","triggerScenarios":"Calling filesys.WriteTree (or any transaction that saves a tree) when the filelock write to the .sy path fails — read-only filesystem, disk quota exceeded, antivirus/backup locking the file, or invalid path.","commonSituations":"Disk full on the workspace volume, data directory on a read-only or unmounted mount, Windows file lock held by a sync/backup client, or insufficient permissions after moving the workspace.","solutions":["Check free disk space and the read cause (%s in the message) for the underlying OS error.","Verify the workspace data directory is writable by the kernel process.","Close applications holding locks on the .sy file (backup/AV tools) and retry the operation."],"exampleFix":"// before: workspace on read-only mount, WriteTree fails\n// after: remount volume read-write or move workspace to writable path, then retry WriteTree","handlingStrategy":"retry","validationCode":"// Go\nif st, err := os.Stat(filepath.Dir(filePath)); err != nil || !isWritableDir(st) { /* surface config problem first */ }","typeGuard":null,"tryCatchPattern":"if err := filesys.WriteTree(tree); err != nil {\n    if strings.Contains(err.Error(), \"write data\") {\n        logging.LogErrorf(\"persist failed: %v\", err)\n        // check disk space / permissions, then retry once\n    }\n}","preventionTips":["Monitor workspace disk free space","Keep the data directory off read-only/network mounts prone to lock issues","Exclude the workspace from antivirus real-time locking where possible"],"tags":["filesystem","write","io"],"backgroundTag":"file-write-failed","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"}