Software /
code /
prosody
Comparison
util/datamanager.lua @ 7928:9d014aca766f
util.datamanager: Use atomic store function when writing the first entry of a list
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 01 Mar 2017 17:15:56 +0100 |
parent | 7927:7132abcf669e |
child | 7929:4017ea6d2599 |
comparison
equal
deleted
inserted
replaced
7927:7132abcf669e | 7928:9d014aca766f |
---|---|
226 local filename = getpath(username, host, datastore, ext, true); | 226 local filename = getpath(username, host, datastore, ext, true); |
227 | 227 |
228 local ok; | 228 local ok; |
229 local f, msg = io_open(filename, "r+"); | 229 local f, msg = io_open(filename, "r+"); |
230 if not f then | 230 if not f then |
231 return atomic_store(filename, data); | |
231 -- File did probably not exist, let's create it | 232 -- File did probably not exist, let's create it |
232 f, msg = io_open(filename, "w"); | |
233 if not f then | |
234 return nil, msg, "open"; | |
235 end | |
236 end | 233 end |
237 | 234 |
238 local pos = f:seek("end"); | 235 local pos = f:seek("end"); |
239 ok, msg = fallocate(f, pos, #data); | 236 ok, msg = fallocate(f, pos, #data); |
240 if not ok then | 237 if not ok then |