{"record":{"id":"b212ded490cd0a5c","repo":"ipfs/kubo","slug":"cp-cannot-flush-the-created-file-s-parent-folder","errorCode":null,"errorMessage":"cp: cannot flush the created file's parent folder %s: %s","messagePattern":"cp: cannot flush the created file's parent folder (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/commands/files.go","lineNumber":606,"sourceCode":"\n\t\tflush, _ := req.Options[filesFlushOptionName].(bool)\n\n\t\tif err := updateNoFlushCounter(nd, flush); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = mfs.PutNode(nd.FilesRoot, dst, node)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cp: cannot put node in path %s: %s\", dst, err)\n\t\t}\n\t\tif flush {\n\t\t\tif _, err := mfs.FlushPath(req.Context, nd.FilesRoot, dst); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot flush the created file %s: %s\", dst, err)\n\t\t\t}\n\t\t\t// Flush parent to clear directory cache and free memory.\n\t\t\tparent := gopath.Dir(dst)\n\t\t\tif _, err = mfs.FlushPath(req.Context, nd.FilesRoot, parent); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot flush the created file's parent folder %s: %s\", dst, err)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t},\n}\n\nfunc getNodeFromPath(ctx context.Context, node *core.IpfsNode, api iface.CoreAPI, p string) (ipld.Node, error) {\n\t// A content path or native IPFS URI (/ipfs/cid, ipfs://cid, /ipns/name, ...)\n\t// is resolved through the DAG. Anything else is treated as an MFS path.\n\tif pth, err := path.NewPathFromURI(p); err == nil {\n\t\treturn api.ResolveNode(ctx, pth)\n\t}\n\n\tfsn, err := mfs.Lookup(node.FilesRoot, p)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L588-L624","documentation":"After flushing the created file, `ipfs files cp` also flushes the parent directory to clear MFS directory caches and free memory; this error wraps a failure of mfs.FlushPath on gopath.Dir(dst). The file itself was placed and flushed, but the parent directory state could not be persisted.","triggerScenarios":"Running `ipfs files cp` with flush enabled where flushing the parent directory of dst fails — usually the same underlying causes as file flush failures (datastore errors, disk full) or a corrupt/unresolvable parent path.","commonSituations":"Disk-full during directory DAG serialization; the parent directory is a large HAMT whose flush hits datastore errors; parent path concurrently renamed/removed by another MFS writer.","solutions":["Check disk space and daemon logs for datastore errors","Run `ipfs files flush /` and retry the copy","Avoid concurrent MFS writes to the same subtree from multiple clients","If persistent, restart the daemon and verify the copied file exists via `ipfs files stat <dst>`"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify parent is a healthy directory before cp\nout, err := run(\"ipfs\", \"files\", \"stat\", filepath.Dir(dst))\nif err != nil || !strings.Contains(out, \"directory\") { return err }","typeGuard":null,"tryCatchPattern":"if err := ipfsFilesCp(src, dst); err != nil {\n    if strings.Contains(err.Error(), \"cannot flush the created file's parent\") {\n        // file likely placed; run `ipfs files flush /` and verify with files stat\n    }\n}","preventionTips":["Flush the whole root (`ipfs files flush /`) after bulk copies","Avoid renaming/removing parent dirs concurrently with cp","Check datastore health if parent flushes fail repeatedly"],"tags":["mfs","cli","flush"],"backgroundTag":"mfs-flush-failed","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}