Comparison

util/datamanager.lua @ 5065:acfaf771f10e

util.datamanager: Don't use os.rename on non-POSIX. It doesn't overwrite exisitng files on Windows.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 01 Aug 2012 01:36:34 +0500
parent 5057:1e44678b5de2
child 5069:7b298f8bcbcb
comparison
equal deleted inserted replaced
5064:7a1eb302c562 5065:acfaf771f10e
169 if f then f:close(); end 169 if f then f:close(); end
170 os_remove(scratch); 170 os_remove(scratch);
171 return nil, msg; 171 return nil, msg;
172 end 172 end
173 173
174 if prosody.platform ~= "posix" then
175 -- os.rename does not overwrite existing files on Windows
176 -- TODO We could use Transactional NTFS on Vista and above
177 function atomic_store(filename, data)
178 local f, err = io_open(filename, "w");
179 if not f then return f, err; end
180 local ok, msg = f:write(data);
181 if not ok then f:close(); return ok, msg; end
182 return f:close();
183 end
184 end
185
174 function store(username, host, datastore, data) 186 function store(username, host, datastore, data)
175 if not data then 187 if not data then
176 data = {}; 188 data = {};
177 end 189 end
178 190