Software /
code /
prosody
Changeset
5066:4be7093edde9
util.datamanager: Try to open in read+write mode, then retry with write mode if that fails (usually because it doesn't exist)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 31 Jul 2012 23:34:11 +0200 |
parents | 5057:1e44678b5de2 |
children | 5067:7db1056c63a9 |
files | util/datamanager.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/datamanager.lua Tue Jul 31 08:23:55 2012 +0200 +++ b/util/datamanager.lua Tue Jul 31 23:34:11 2012 +0200 @@ -201,7 +201,10 @@ 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;