aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamanager.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2012-08-01 01:36:34 +0500
committerWaqas Hussain <waqas20@gmail.com>2012-08-01 01:36:34 +0500
commit2161f2e88c3b8b882fc30ec49609d4262d18e380 (patch)
tree8c0d518b1405058b1910b67ba4cd44827092a4d1 /util/datamanager.lua
parent57b3f76efccad9e5bc7b5f89664d607d02a5b45c (diff)
downloadprosody-2161f2e88c3b8b882fc30ec49609d4262d18e380.tar.gz
prosody-2161f2e88c3b8b882fc30ec49609d4262d18e380.zip
util.datamanager: Don't use os.rename on non-POSIX. It doesn't overwrite exisitng files on Windows.
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r--util/datamanager.lua12
1 files changed, 12 insertions, 0 deletions
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 = {};