DOI-BOR / PyForecast

PyForecast is a statistical modeling tool used by Reclamation water managers and reservoir operators to train and build predictive models for seasonal inflows and streamflows. PyForecast allows users to make current water-year forecasts using models developed with the program.
Other
28 stars 12 forks source link

Saving Bug #23

Closed tjrocha closed 5 years ago

tjrocha commented 5 years ago

If the software crashes while it is trying to save to an existing .fcst file, the file is emptied out and all the work contained within it is lost. Propose saving to a .temp.fcst file first before doing a rename/overwrite of the existing *.fcst file.

Hard to reproduce, the software needs to crash while doing a save.

tjrocha commented 5 years ago

Rolling back change... Need to come up with an alternative solution. Fails from compiled installer...

blounsbury-usbr commented 5 years ago

No sure why I'm investigating, curiosity killed the cat? Looks like shutil.move() will fail if the file exists on Windows.

See here: https://docs.python.org/3.7/library/shutil.html#shutil.move "If the destination is on the current filesystem, then os.rename() is used."

Then os.rename(): https://docs.python.org/3.7/library/os.html#os.rename "On Windows, if dst exists a FileExistsError is always raised."

Looks like an os.replace() instead of shutil.move() would work.