# HG changeset patch # User Kim Alvefur # Date 1343770451 -7200 # Node ID 4be7093edde9a4b2e265e837ec31be5db85aa54e # Parent 1e44678b5de2e77787794d7de585a5920dbb01b0 util.datamanager: Try to open in read+write mode, then retry with write mode if that fails (usually because it doesn't exist) diff -r 1e44678b5de2 -r 4be7093edde9 util/datamanager.lua --- 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;