tigris-mt / elevator

An entity-based elevator allowing fast realtime travel in Minetest.
https://forum.minetest.net/viewtopic.php?f=9&t=17079
Other
4 stars 14 forks source link

save_elevator() fails to os.rename "elevator.tmp" to "elevator" when "elevator" exists. #4

Closed diegovgsilva95 closed 6 years ago

diegovgsilva95 commented 6 years ago

The function save_elevator() (line 31) creates a temporary file (line 32), then writes the serialized string of elevator table in that temporary file (line 33), then renames it to "elevator" (line 35). The problem is: when destination filename exists, os.rename fails.

TODO: after closing the temporary file (line 34), delete the file "elevator" (os.remove), of course checking if it succeeds, before renaming "elevator.tmp" to "elevator", also checking if rename succeeded.