util.datamanager: Handle potential error from :write() call
authorKim Alvefur <zash@zash.se>
Fri, 11 Dec 2015 19:26:04 +0000 (20:26 +0100)
committerKim Alvefur <zash@zash.se>
Fri, 11 Dec 2015 19:26:04 +0000 (20:26 +0100)
util/datamanager.lua

index 3016feed8beb224ba79bfbc666615ec72a825393..ce4c5b5a22722270fb4fa86aecf478d3359248b9 100644 (file)
@@ -232,9 +232,9 @@ local function append(username, host, datastore, ext, data)
                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