When we start up, if we can't load our persistent state, we'll currently exit with an error. That's not good user experience: instead we should maybe move aside any broken/unreadable state files? Or perhaps we should ignore them and not use persistent state? There are multiple possibilities here, and it's not obvious which is best.
Designs
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
tl;dr: I think we should just improve the error messages here, and take no other action for now.
Okay, so here are the principles I'd like to go with:
We should never delete stuff that we don't understand.
We should probably not move data aside just because we think it might be corrupted.
Therefore, our best move is probably to make sure that all of our error messages say what is broken, and what you would need to do to fix it.
That's done partially by !614 (merged), where we made sure that each error message about persistent state says what file is at issue. As I keep making fixes for #323 (closed), I'll try to make sure more error messages still say what the problem files are (if any). But see #514 (closed): We might decide that logging filenames by default is problematic!
It might be a good idea to expose a list of maybe-broken files via an API on arti_client::Error.
We should revisit these principles if we find that any particular type of file corruption happens in practice. We ought to be relatively resistant to such corruption, since for now we've only got three types of files in our directories:
Files that we create with the "write, close, rename" pattern, which is "pretty atomic".
Sqlite3 databases, which are pretty robust.
Lock files, which have no content.
Therefore, I'd suspect that the likeliest causes of data corruption would be bugs in our code, or bugs in other code that's messing with our files when it shouldn't.
I dare to suggest that suggesting the user blows away all of arti's state might be reasonable - assuming the user doesn't experience this often. OTOH maybe that option is obvious to the user. OTTH they may not know what to delete.
Those ideas look good to me! I'd second Diziet's opinion that ideally, it'd be nice to have some form of error help message that would explain how to get it going again (like help: to blow away all the state files, remove or move /path/to/directory or somesuch).
This is problematic on Android, where state directory is likely to be internal to app and even with advanced file manager capable of understanding the path you can't touch it, unless the phone is rooted. Erasing the app data would help, but it's too aggressive.