From d5624ca8e0689397c43a089da8e43f06a4658125 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Fri, 15 May 2015 15:25:37 +0200
Subject: mod_storage_xep0227: Open file for writing even if removing so
 os.remove has a file to delete

---
 plugins/mod_storage_xep0227.lua | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'plugins')

diff --git a/plugins/mod_storage_xep0227.lua b/plugins/mod_storage_xep0227.lua
index b41fc6ce..22575fe3 100644
--- a/plugins/mod_storage_xep0227.lua
+++ b/plugins/mod_storage_xep0227.lua
@@ -23,14 +23,15 @@ end
 local function setXml(user, host, xml)
 	local jid = user.."@"..host;
 	local path = paths.join(prosody.paths.data, jid..".xml");
+	local f = io_open(path, "w");
+	if not f then return; end
 	if xml then
-		local f = io_open(path, "w");
-		if not f then return; end
 		local s = tostring(xml);
 		f:write(s);
 		f:close();
 		return true;
 	else
+		f:close();
 		return os_remove(path);
 	end
 end
-- 
cgit v1.2.3