aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-07-31 23:34:11 +0200
committerKim Alvefur <zash@zash.se>2012-07-31 23:34:11 +0200
commitb20cc7f5d7fea64c97b4810f71d35a544d6b2b42 (patch)
tree2f0d62f164d5561be6eb110ce34b69f004f2f74d /util/datamanager.lua
parentd434226dbe1029b47f12569b7f91bddd90da621b (diff)
downloadprosody-b20cc7f5d7fea64c97b4810f71d35a544d6b2b42.tar.gz
prosody-b20cc7f5d7fea64c97b4810f71d35a544d6b2b42.zip
util.datamanager: Try to open in read+write mode, then retry with write mode if that fails (usually because it doesn't exist)
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 79be07b0..c8b905ac 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -201,7 +201,10 @@ function list_append(username, host, datastore, data)
if not data then return; end
if callback(username, host, datastore) == false then return true; end
-- save the datastore
- local f, msg = io_open(getpath(username, host, datastore, "list", true), "a");
+ local f, msg = io_open(getpath(username, host, datastore, "list", true), "r+");
+ if not f then
+ f, msg = io_open(getpath(username, host, datastore, "list", true), "w");
+ end
if not f then
log("error", "Unable to write to %s storage ('%s') for user: %s@%s", datastore, msg, username or "nil", host or "nil");
return;