ipfs/kubo · warning

cp: cannot flush the created file's parent folder

Error message

cp: cannot flush the created file's parent folder %s: %s

What it means

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.

Solutions

  1. Check disk space and daemon logs for datastore errors
  2. Run `ipfs files flush /` and retry the copy
  3. Avoid concurrent MFS writes to the same subtree from multiple clients
  4. If persistent, restart the daemon and verify the copied file exists via `ipfs files stat <dst>`
Defensive patterns

Strategy: retry

Validate before calling

// verify parent is a healthy directory before cp
out, err := run("ipfs", "files", "stat", filepath.Dir(dst))
if err != nil || !strings.Contains(out, "directory") { return err }

Try / catch

if err := ipfsFilesCp(src, dst); err != nil {
    if strings.Contains(err.Error(), "cannot flush the created file's parent") {
        // file likely placed; run `ipfs files flush /` and verify with files stat
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/b212ded490cd0a5c. Report an issue: GitHub.

Appendix: source

Thrown at core/commands/files.go:606

		flush, _ := req.Options[filesFlushOptionName].(bool)

		if err := updateNoFlushCounter(nd, flush); err != nil {
			return err
		}

		err = mfs.PutNode(nd.FilesRoot, dst, node)
		if err != nil {
			return fmt.Errorf("cp: cannot put node in path %s: %s", dst, err)
		}
		if flush {
			if _, err := mfs.FlushPath(req.Context, nd.FilesRoot, dst); err != nil {
				return fmt.Errorf("cp: cannot flush the created file %s: %s", dst, err)
			}
			// Flush parent to clear directory cache and free memory.
			parent := gopath.Dir(dst)
			if _, err = mfs.FlushPath(req.Context, nd.FilesRoot, parent); err != nil {
				return fmt.Errorf("cp: cannot flush the created file's parent folder %s: %s", dst, err)
			}
		}

		return nil
	},
}

func getNodeFromPath(ctx context.Context, node *core.IpfsNode, api iface.CoreAPI, p string) (ipld.Node, error) {
	// A content path or native IPFS URI (/ipfs/cid, ipfs://cid, /ipns/name, ...)
	// is resolved through the DAG. Anything else is treated as an MFS path.
	if pth, err := path.NewPathFromURI(p); err == nil {
		return api.ResolveNode(ctx, pth)
	}

	fsn, err := mfs.Lookup(node.FilesRoot, p)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 329838acdf)