ncssar / radiolog

SAR radio log program
Other
13 stars 3 forks source link

if .csv about to be loaded / recovered is corrupted, automatically try the latest backup .csv #614

Closed caver456 closed 1 year ago

caver456 commented 1 year ago

Encountered 1/15/23 after power was lost to the IC trailer. After power came back and dispatch computer was started, radiolog detected the crash and offered to restore the files. On clicking Yes, a traceback came up during the load function, simply saying '_csv.Error: line contains NUL' Looking at the .csv file, it was completely corrupted. The immediate solution was to load the _bak1.csv file instead, by renaming it to have the 'main' .csv filename (without _bak in the name) then restarting and loading - (probably didn't actually need to rename it - probably could have browsed directly to the _bak1.csv file) - so, up to five of the most recent entries were lost. Radiolog could be made to do this search automatically: put the load command in a try/except clause; if load fails, try the next _bak file in line, until all _bak files have been tried. After the load attempt loop is finished, show a messagebox that says what files failed, what file was ultimately loaded, and how many of the most recent entries may have been lost.

caver456 commented 1 year ago

At the core, this involved making load() recursive: if the first file throws an exception while reading the rows, it will cycle through _bak1 to _bak5, and if the backup file exists, it will be loaded. If no backup file is valid (or no backup files are found), it will show a message saying so. Also required some recoding in getSessions and isRadioLogDataFile.

caver456 commented 1 year ago

during the course of cleanup after merge commit on NXDN branch, improved this issue to also raise an exception (therefore try the next bak file in sequence) if a row doesn't have enough columns, indicating possible file corruption (and this case was also easier to create a test case for)