Closed HalosGhost closed 9 years ago
Process for locating the database:
$XDG_CONFIG_HOME
exists.
$XDG_CONFIG_HOME/pbpst/
exists.
$XDG_CONFIG_HOME/pbpst/db.json
exists.$XDG_CONFIG_HOME/pbpst/db.json
.$HOME/.config/pbpst/db.json
exists.
Yes, this is a ton of steps just to ensure that we have a database. But, to preserve sanity and functionality, we need all of them.
I'm pushing the db initialization to a little later in the stage so it'll be handled by writing the default to the swap db rather than writing the default to the main db for read-in. I may change my mind about this when we get to the swap db code handling; but, for now, that's the plan.
Edit: I found a great middle-ground. If the db we try to read in is empty, we read in the default db to the internal memory instead, and then the rest of the program executes as normal. This means there is only one special case to deal with the db init, that supporting an option exclusively to initialize the db is a cakewalk, and that we still do not need to worry about reading and writing to the same file.
via 84b3086
Prerequisites:
We need to get the local database up and running so we can simplify the output we give on successful completion and so we can support a lot of the planned options.
Things which must work to close: