Diff

util/datamanager.lua @ 6998:86607fe755b6

util.datamanager: Handle potential error from :write() call
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 20:26:04 +0100
parent 6997:0ab228bc21c6
child 6999:0ad66d12113a
line wrap: on
line diff
--- a/util/datamanager.lua	Fri Dec 11 20:24:36 2015 +0100
+++ b/util/datamanager.lua	Fri Dec 11 20:26:04 2015 +0100
@@ -232,9 +232,9 @@
 		f:seek("set", pos);
 	end
 
-	if ok then
-		f:write(data);
-	else
+	ok, msg = f:write(data);
+	if not ok then
+		f:close();
 		return ok, msg;
 	end