Software /
code /
prosody
Diff
util/datamanager.lua @ 5069:7b298f8bcbcb
Merge Waqas<>Zash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 31 Jul 2012 23:07:02 +0100 |
parent | 5066:4be7093edde9 |
parent | 5065:acfaf771f10e |
child | 5095:dddbcd62183a |
line wrap: on
line diff
--- a/util/datamanager.lua Tue Jul 31 23:43:34 2012 +0200 +++ b/util/datamanager.lua Tue Jul 31 23:07:02 2012 +0100 @@ -171,6 +171,18 @@ 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 = {};