cointop-sh / cointop

A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
https://cointop.sh
Apache License 2.0
4.05k stars 314 forks source link

BUG: configuration file is corrupted if multiple instances of cointop are run at once. #305

Open monomadic opened 2 years ago

monomadic commented 2 years ago

I use cointop for showing price data and my portfolio totals in waybar in sway. Within a few updates, the coinfiguration file is corrupted - I'm fairly sure there's no locking on the file during write because it produces an invalid TOML file. This has a side effect of completely deleting my portfolio.

I would highly recommend splitting up this configuration file into practical use - there is absolutely NO reason whatever one would want to write a configuration file every single time you open an application. If you are doing this it suggests you should be storing something in .local/ or .cache/ instead.

Also consider storing portfolio data in a separate file (it belongs in .local actually) as this is not configuration - think of what you'd use, say, nixos or stow or a dotfiles manager for - you want to store your settings, not personal information.

Regardless, writes are highly destructive and should always be treated with care.

lyricnz commented 2 years ago

We always try and maintain backward-compatability with the config file format. Have you got any specific example of corruption?

There are a couple of tickets to improve the state of configuration/etc #238 in particular expresses the same sentiment.

MostHated commented 2 years ago

Unfortunately, I have been having this issue for a while, to the point where I created a backup config, and when my script detects an error, it takes the backup config and writes it over the messed-up config to try and restore itself. It used to work pretty well, until I just recently updated to the latest version. It's got worse for some reason and is now happening within minutes of starting my scheduler (even at 20+ second intervals of attempting to query it still keeps happening) and it can't recover.