ipfs / ipfs/kubo

Copying /ipfs/{cid} to MFS changes CID in some cases

Open
#10,262 4 comments 0 reactions 0 assignees View on GitHub
effort/days kind/bug P2
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] This is a bug report, not a question. Ask questions on [discuss.ipfs.io](https://discuss.ipfs.io).
- [X] I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my bug.
- [X] I am running the latest [kubo version](https://dist.ipfs.tech/#kubo) or have an issue updating.

### Version

```Text
Kubo version: 0.26.0-dev-78e2fab7c
Repo version: 15
System version: arm64/darwin
Golang version: go1.21.5
```

### Description

When copying certain files from an `/ipfs/` path to the MFS, its CID in the MFS is not the same as originally. So far I could only reproduce it with `bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y` which is a fixture for IPIP-288:

```bash
$ ipfs files cp /ipfs/bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y /my-file
$ ipfs files ls -l /
my-file/ bafybeifixkapxaka2kautztgu2he7xuecmzdfd3tcrisy56ogjat3udt3u 0
```

DAG inspection for `bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y` (original):

```json
{
"Data": {
"/": {
"bytes": "CAE"
}
},
"Links": [
{
"Hash": {
"/": "bafybeiaepusisfkk2vbytkixo56l4l4m3tohrm6t22uyzpl3an3pouwbku"
},
"Name": "foobar",
"Tsize": null
}
]
}
```

DAG inspection for `bafybeifixkapxaka2kautztgu2he7xuecmzdfd3tcrisy56ogjat3udt3u` (after copy):

```json
{
"Data": {
"/": {
"bytes": "CAE"
}
},
"Links": [
{
"Hash": {
"/": "bafybeiaepusisfkk2vbytkixo56l4l4m3tohrm6t22uyzpl3an3pouwbku"
},
"Name": "foobar",
"Tsize": 0
}
]
}
```

It seems that it changes the `Tsize` from `null` to `0`. Not sure if this is expected. However, I would definitely not expect to have a different CID after copying a file to MFS. After all, it's just supposed to add a reference there for the exact same CID.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.