attempt to recover from various invalid session forms... #209 #218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regardless of fixing the way these files can get corrupted like this. Simply a brew session that misses a "complete" or otherwise isn't marked correctly as finished (existing or otherwise) we should look at recovering as many as we can (short of a power outage in the middle of writing a line in the file).
A long term fix for "invalid written JSON structure" can be found in #216 and I'll defer fixing the "problem" until then. I've run this locally where on my system I have 6 different types of invalid sessions across the different types of devices and this fixes nearly all of them (short of the session files that have invalid names ie '#' in the filename, wrong date string, non integer, etc).
current behavior with the new try/except handling from another PR
invalid sessions (if the contents aren't parsable, but the filename is valid) show up as empty sessions now
proposed session recovery change
with this proposed session recovery change (we should likely update again a bit later to just re-write the file if the session is recovered successfully...)
cc/ @Rudder2 I've tested in the above screenshot with your invalid RINSE and invalid HopHeads files here as well.