nuclear
nuclear copied to clipboard
Detect and handle broken config
A broken config file can easily crash the program. Nuclear should be able to detect this problem and either reset the config, or fix the broken parts. Somewhere within the code that loads the config should be a try-catch block that does this.
can u give more detail like where exactly like where config file
The config is managed by electron-store
. Loading happens here: https://github.com/nukeop/nuclear/blob/master/packages/main/src/services/store/index.ts
Hi, Anybody working on this?
I don't think anyone is working on it yet, do you want to take it?
I will give it a try, thanks.
Hi, is this issue still open? Care if I take it?
@Pranjal-dew how are you going to approach this?
Sure, that would be great. You can find a description of the architecture here: https://nukeop.gitbook.io/nuclear/developer-resources/architecture
And the docs also have a section about contribution guidelines.
Sure, that would be great. You can find a description of the architecture here: https://nukeop.gitbook.io/nuclear/developer-resources/architecture
And the docs also have a section about contribution guidelines.
On second thought I think I will have to drop the isseu for the time being.
I will reevalute a bit later.
Thanks.
@nukeop Just to confirm, is anyone working on this?
@nukeop I'm going to work on this.
Great, I was thinking this could be solved better with versioning (this would require storing the version number in the config and allow defining migrations). Other things that will need to be versioned at some point are db schemes and the local library index.
I see, I'll keep you updated if anything comes up.
@nukeop Can you give me an example of the config breaking? I text you on discord too in the help channel.
As the first step, you can try using JSON.parse (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) and checking if it returns an error.
If it does, fallback to an empty config with default values.
As a next step, we could define a schema for the config (including settings, playlists, and favorites) and check if it complies with it. If there are errors, then that part of the config can either be migrated, or reset. You can use yup for this: https://www.npmjs.com/package/yup
the config should also contain a "version" key that defines what schema it should follow
I see, thankyou.