soyuka / dat-daemon

Dat as a daemon
MIT License
25 stars 3 forks source link

Flag for "datdaemon add" to not complain if a hash already exists #12

Closed mitar closed 6 years ago

mitar commented 6 years ago

Currently it dies, which makes it hard to script (because i would like to differentiate between already added and other errors).

soyuka commented 6 years ago

https://github.com/soyuka/dat-daemon/blob/master/index.js#L48

Need to test this :|. Thanks for the report.

soyuka commented 6 years ago

Wait in fact you should be able to test this just fine, it exits with a code 1, would another code do the trick?

mitar commented 6 years ago

Does it always exit with 1 only if the key is already added? No other cause makes it exist with 1?

So I imagine something like rm -f flag, which makes rm exist with 0. So then I would not even have to check the return code value. (And generally it is hard to assure that the return code is not reused because some other library might exit with 1 for example for some other reason.)

soyuka commented 6 years ago

Exits with code 2 in this case :).

mitar commented 6 years ago

Thanks!