ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.11k stars 3.01k forks source link

`files write --create` should not rewrite already existing files #7080

Closed RubenKelevra closed 2 years ago

RubenKelevra commented 4 years ago

Version information:

go-ipfs version: 0.4.23-6ce9a355f Repo version: 7 System version: amd64/linux Golang version: go1.14

Description:

Currently, a files write do rewrite a file, when --create is set. This was quite unexpected to me, I thought --create will make sure that if needs to create a file and won't modify an already existing one, like a write without --create will make sure there's a file to modify and it won't create a new one.

Steps to reproduce

$ ipfs files rm /test
Error: file does not exist
$ cat fileA.txt | ipfs files write --create /test
$ ipfs files stat /test
QmABC
Size: 71
CumulativeSize: 129
ChildBlocks: 1
Type: file
[ipfs@loki ~]$ cat fileA.txt | ipfs files write --create /test
[ipfs@loki ~]$ ipfs files stat /test
QmCDE
Size: 110
CumulativeSize: 220
ChildBlocks: 2
Type: file
Stebalien commented 4 years ago

This is following the unix convention, we don't have an "EXCL" flag.

schomatis commented 2 years ago

I think this is working as expected (alternatively we could add a "don't overwrite" flag, but that should happen in a separate enhancement issue I think). Closing for now.