[Oxyd] 0.12 world deleted

This subforum contains all the issues which we already resolved.
Post Reply
Riley19280
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Jul 17, 2015 11:36 pm
Contact:

[Oxyd] 0.12 world deleted

Post by Riley19280 »

so as i was going to upload the world for another bug report while i was still playing on that world i got an access is denied world and now there is no world save in the game or in the saves folder.

0.011 2015-07-17 19:57:34; Factorio 0.12.0 (Build 103, win64)
0.011 Operating system: Windows 8
0.011 Read data path: C:/Program Files/Factorio/data
0.011 Write data path: C:/Users/Riley/AppData/Roaming/Factorio
0.011 Binaries path: C:/Program Files/Factorio/bin
0.101 Initialised Direct3D: NVIDIA GeForce GTX 970; driver: nvd3dumx.dll 9.18.13.4752
0.166 Graphics options: [FullScreen: true] [VSync: true] [UIScale: 100%] [MultiSampling: OFF] [Graphics quality: normal] [Video memory usage: all]
0.248 Loading mod core 0.0.0 (data.lua)
0.252 Loading mod base 0.12.0 (data.lua)
1.235 Initial atlas bitmap size is 16384
1.239 Created atlas bitmap 16384x7658
12.863 Info Updater.cpp:720: Downloading https://www.factorio.com/updater/get-av ... iVersion=2
13.221 0 packages available to download (experimental updates disabled).
13.257 Factorio initialised
16.532 Loading map C:/Users\Riley\AppData\Roaming\Factorio\saves\NO2.zip
16.771 Info Scenario.cpp:160: Map version 0.12.0-36
4149.679 Warning FileUtil.cpp:234: C:/Users\Riley\AppData\Roaming\Factorio\temp\currently-saving_437d9c10 was read only, the read only flag had to be removed so it can be deleted.
4149.700 Error Util.cpp:45: boost::filesystem::status: Access is denied: "C:/Users\Riley\AppData\Roaming\Factorio\saves\NO2.zip"
4154.376 Goodbye

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: 0.12 world deleted

Post by Oxyd »

Riley19280 wrote:4149.679 Warning FileUtil.cpp:234: C:/Users\Riley\AppData\Roaming\Factorio\temp\currently-saving_437d9c10 was read only, the read only flag had to be removed so it can be deleted.
4149.700 Error Util.cpp:45: boost::filesystem::status: Access is denied: "C:/Users\Riley\AppData\Roaming\Factorio\saves\NO2.zip"
Do you have write access to C:/Users\Riley\AppData\Roaming\Factorio\saves ? How did you start Factorio? Did you start it as a different user (as Administrator, perhaps?)?

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: 0.12 world deleted

Post by Oxyd »

Also do you have any anti-virus software installed on your computer? Do you know if it was doing something when this happened? Such as scanning your PC.

Riley19280
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Jul 17, 2015 11:36 pm
Contact:

Re: 0.12 world deleted

Post by Riley19280 »

yea it was while i was uploading the world to here, but the world should not delete itself if this happens

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: 0.12 world deleted

Post by Oxyd »

Aha. On Windows, when a process reads file, it locks it so other processes can't write it. This might be it. I still wonder how it could've been deleted when it was locked.

I agree it shouldn't be deleted.

Riley19280
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Jul 17, 2015 11:36 pm
Contact:

Re: 0.12 world deleted

Post by Riley19280 »

that is what happened luckly autosave ftw!

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [Oxyd] 0.12 world deleted

Post by Oxyd »

I made some changes to the saving code, so hopefully there won't be any more issues like this.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: [Oxyd] 0.12 world deleted

Post by SilverWarior »

I don't know how savegame mechanism is implemented in factorio but as a hobby game developer myself I would suggest something like this.

1. Once the savegame process begins make copy of the old savegame. Now when I say make copy I don't mean go create a new file and copy contents of old savegame into it. Instead I mean rename the old savegame file to something like savegamename.bak
2. Create a new file in which you will save the current game
3. OPTIONAL Execute some savegame structure verification algorithm to check that savegame was successfully saved
4. If no error ocured during the savegame process and optionally if savegame structure verification algorithm confirmed everything went wll you delete the old savegame backup you made before. If some error occurred you can always rename old savegame back to original name.

Advantages of this approach:
- you always have a backup copy to revert to in case if error occurred during savegame process
- since you are just renaming old savegame file into backup file this is done quickly and there is no danger of data damage (even in case of power loss) as if you would be copying data into backup file.

Drawback of this approach:
- you need double space on HDD because for the moment you have two savegames present on it (both backup of old and new savegame file)
- could possibly cause HDD fragmentation

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [Oxyd] 0.12 world deleted

Post by Oxyd »

SilverWarior wrote:since you are just renaming old savegame file into backup file this is done quickly and there is no danger of data damage (even in case of power loss) as if you would be copying data into backup file.
Yeaaah, that was the reasoning behind our current saving code, I'm sure.

What Factorio does is the following: It saves the map in a temporary location, then moves it from that temporary location into saves. Sounds good in theory, eh? The problem in this particular case is that Factorio actually deleted the old save before moving the new one into place. But, moving is not guaranteed to succeed, so it's possible that you're suddenly left with nothing in saves and only the new save in the temporary location. To make matters worse, the code isn't too good with error-checking, so it will actually delete the temporary location as well, even when the move failed.

Reading the code, I'm actually surprised a little this is the first report of a file being eaten I've seen yet. I can only heartily recommend back-ups.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: [Oxyd] 0.12 world deleted

Post by SilverWarior »

Oxyd wrote:What Factorio does is the following: It saves the map in a temporary location, then moves it from that temporary location into saves.
That is terrible approach. Why? First the temporary location may not be on the same disk drive as the actual savegame should be. So you have no way of making sure there is enough disk space available.
Also contents of the temporary folder could get deleted by some third party "cleaning" application. In practice this means that short period between closing file after you are done writing data to it and the time you issue move/rename command the file is actually available to be manipulated by any other application.
Not to mention that such approach would cause AV software to check that savegame file twice. Once while the data is being written into it. And gain after the file is moved to final folder.
Oxyd wrote:Reading the code, I'm actually surprised a little this is the first report of a file being eaten I've seen yet. I can only heartily recommend back-ups.
Based on what you sad I'm also surprised this didn't happen before.

So I would strongly recommend using of my approach. Especially since I have shared this idea with a several other game developers already and all of them were happy with it since it solved several different problems they had before.

Post Reply

Return to “Resolved Problems and Bugs”