diff options
author | Kim Alvefur <zash@zash.se> | 2012-07-31 23:34:11 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-07-31 23:34:11 +0200 |
commit | 5539608830c46a26d95f364acdf21789e0035f6f (patch) | |
tree | 2f0d62f164d5561be6eb110ce34b69f004f2f74d /util/datamanager.lua | |
parent | 161a78b35bd69f748b52989945613809541e26a3 (diff) | |
download | prosody-5539608830c46a26d95f364acdf21789e0035f6f.tar.gz prosody-5539608830c46a26d95f364acdf21789e0035f6f.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.lua | 5 |
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; |