From 5e947f4b086e5818b0aac35fe2bbd2079fbf4077 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 1 Aug 2012 01:36:34 +0500 Subject: util.datamanager: Don't use os.rename on non-POSIX. It doesn't overwrite exisitng files on Windows. --- util/datamanager.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index 79be07b0..ecf90bab 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -171,6 +171,18 @@ local function atomic_store(filename, data) return nil, msg; end +if prosody.platform ~= "posix" then + -- os.rename does not overwrite existing files on Windows + -- TODO We could use Transactional NTFS on Vista and above + function atomic_store(filename, data) + local f, err = io_open(filename, "w"); + if not f then return f, err; end + local ok, msg = f:write(data); + if not ok then f:close(); return ok, msg; end + return f:close(); + end +end + function store(username, host, datastore, data) if not data then data = {}; -- cgit v1.2.3