From be1b771edf344615e31f310259b2793c95c1d217 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 11 Dec 2015 20:24:36 +0100 Subject: util.datamanager: Handle potential issues from fallocate --- util/datamanager.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/datamanager.lua b/util/datamanager.lua index 786abd95..3016feed 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -222,7 +222,16 @@ local function append(username, host, datastore, ext, data) 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 -- cgit v1.2.3