Changeset

6997:0ab228bc21c6

util.datamanager: Handle potential issues from fallocate
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 20:24:36 +0100
parents 6996:644b1bddc676
children 6998:86607fe755b6
files util/datamanager.lua
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/datamanager.lua	Fri Dec 11 20:22:54 2015 +0100
+++ b/util/datamanager.lua	Fri Dec 11 20:24:36 2015 +0100
@@ -222,7 +222,16 @@
 	end
 	local pos = f:seek("end");
 	ok, msg = fallocate(f, pos, #data);
-	f:seek("set", pos);
+	if not ok then
+		log("warn", "fallocate() failed: %s", tostring(msg));
+		-- This doesn't work on every file system
+	end
+
+	if f:seek() ~= pos then
+		log("debug", "fallocate() changed file position");
+		f:seek("set", pos);
+	end
+
 	if ok then
 		f:write(data);
 	else