mirror of
				https://github.com/minetest-mods/areas.git
				synced 2025-10-31 13:05:21 +01:00 
			
		
		
		
	Don't overwrite area file if serialization fails
This commit is contained in:
		| @@ -5,11 +5,16 @@ end | |||||||
|  |  | ||||||
| -- Save the areas table to a file | -- Save the areas table to a file | ||||||
| function areas:save() | function areas:save() | ||||||
|  | 	local datastr = minetest.serialize(self.areas) | ||||||
|  | 	if not datastr then | ||||||
|  | 		minetest.log("error", "[areas] Failed to serialize area data!") | ||||||
|  | 		return | ||||||
|  | 	end | ||||||
| 	local file, err = io.open(self.filename, "w") | 	local file, err = io.open(self.filename, "w") | ||||||
| 	if err then | 	if err then | ||||||
| 		return err | 		return err | ||||||
| 	end | 	end | ||||||
| 	file:write(minetest.serialize(self.areas)) | 	file:write(datastr) | ||||||
| 	file:close() | 	file:close() | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user