Fenixin / Minecraft-Region-Fixer

Python script to fix some of the problems of the Minecraft save files (region files, *.mca).
GNU General Public License v3.0
557 stars 101 forks source link

Scanner silently accepts blocks if opening them for writing fails #72

Open chrysn opened 5 years ago

chrysn commented 5 years ago

When run on MCR files of corrupted chunks that are read-only (as typical of backup files), the scanner silently reports "no problems". It should either report a write error if it is actually necessary to open them write-only, or only open them for writing when necessary.

The current situation causes very hard-to-debug situations when scanning through backups none of which appear to be corrupt, even though any restored data set is shown as corrupt.

Fenixin commented 5 years ago

Thanks for the bug report. I will fix it next time I give this some time.

Fenixin commented 5 years ago

I have tried to reproduce this bug with no success. If I try to open read only regionfiles a PermissionError exception is raised. Could you please provide some information about your configuration/system? I have tried this in windows, tomorrow I can test this in linux.

Fenixin commented 5 years ago

Ok, new information.

Regionfixer always open region files in "r+b" mode, that means read and write binary mode. When a file can't be opened in this way it just add the "Unreadable" status to it and it's considered a bad regionfile. This is how the NBT library works right now.

In the branch new2to3 I have added a new status for region files that differentiates between any IOError (for example file system problems) and PermissionError (file cannot be opened in write mode). Also, after this is finished it will be added some description in the wiki.

It's true that that it would be better to open region files in write mode only when needed, but that will be for the future.

I'm going to leave this open, maybe I'm able to code that in some time.