{"record":{"id":"e05981d0f69e368c","repo":"ipfs/kubo","slug":"cp-cannot-flush-the-created-file-s-s","errorCode":null,"errorMessage":"cp: cannot flush the created file %s: %s","messagePattern":"cp: cannot flush the created file (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":601,"sourceCode":"\t\tif force {\n\t\t\tif err = unlinkNodeIfExists(nd, dst); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot unlink existing file: %s\", err)\n\t\t\t}\n\t\t}\n\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}","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L583-L619","documentation":"After successfully placing the node, `ipfs files cp --flush` (flush is enabled by default) flushes the created file via mfs.FlushPath; this error wraps a failure flushing dst itself. The node was placed but its data could not be committed from the in-memory MFS to the DAG service/datastore.","triggerScenarios":"Running `ipfs files cp` with flush enabled where mfs.FlushPath on dst fails — e.g. underlying blockservice/datastore write errors, disk full, or the just-placed path was concurrently removed by another operation.","commonSituations":"Full disk or datastore quota during a large copy; concurrent MFS operations from another CLI/API client removing dst between put and flush; datastore (e.g. badger) corruption.","solutions":["Check disk space and datastore health (`ipfs repo stat`, daemon logs)","Re-run the copy; if dst was concurrently removed, serialize concurrent MFS writers","Run `ipfs files flush /` to reconcile MFS state, then retry","Investigate datastore errors in daemon logs (`GOLOG_LOG_LEVEL=debug ipfs daemon`)"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// check repo headroom before large copies\nrun(\"ipfs\", \"repo\", \"stat\") // verify free space / quota","typeGuard":null,"tryCatchPattern":"err := ipfsFilesCp(src, dst)\nif err != nil && strings.Contains(err.Error(), \"cannot flush the created file\") {\n    time.Sleep(backoff)\n    run(\"ipfs\", \"files\", \"flush\", \"/\")\n    err = ipfsFilesCp(src, dst)\n}","preventionTips":["Monitor disk space for the repo datastore","Serialize MFS writes; avoid concurrent writers to the same path","Run `ipfs files flush /` after bulk operations and check daemon logs"],"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"}