aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-11 20:13:37 +0100
committerKim Alvefur <zash@zash.se>2015-12-11 20:13:37 +0100
commit51302e343c590e887b3b53de95b4afed0df453bb (patch)
tree386e96fe4a748633cc8c5712d2c0c90f0681b769 /util
parent06725746573f7d9800ceed1cb442c993e014fdc4 (diff)
downloadprosody-51302e343c590e887b3b53de95b4afed0df453bb.tar.gz
prosody-51302e343c590e887b3b53de95b4afed0df453bb.zip
util.datamanager: In append() collect status when closing file handle as it may fail (eg the implied flush)
Diffstat (limited to 'util')
-rw-r--r--util/datamanager.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 1993d6a3..4a371d2c 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -210,9 +210,10 @@ local function store(username, host, datastore, data)
end
local function append(username, host, datastore, ext, data)
- local f, msg = io_open(getpath(username, host, datastore, ext, true), "r+");
+ local filename = getpath(username, host, datastore, ext, true);
+ local f, msg = io_open(filename, "r+");
if not f then
- f, msg = io_open(getpath(username, host, datastore, ext, true), "w");
+ f, msg = io_open(filename, "w");
end
if not f then
return nil, msg;
@@ -225,7 +226,12 @@ local function append(username, host, datastore, ext, data)
else
return ok, msg;
end
- f:close();
+
+ ok, msg = f:close();
+ if not ok then
+ return ok, msg;
+ end
+
return true;
end