diff options
author | Kim Alvefur <zash@zash.se> | 2016-02-28 15:06:56 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-02-28 15:06:56 +0100 |
commit | a2e7422c44fa376517b143a317b60042b85a8dc9 (patch) | |
tree | f4be8fd8748b09429e518c34024b79b273d76845 /util/datamanager.lua | |
parent | a50400a3c22434805b4220379070b09930639063 (diff) | |
parent | 29cb6ece54e331e6bed5a042524091f75b43846a (diff) | |
download | prosody-a2e7422c44fa376517b143a317b60042b85a8dc9.tar.gz prosody-a2e7422c44fa376517b143a317b60042b85a8dc9.zip |
Merge 0.10->trunk
Diffstat (limited to 'util/datamanager.lua')
-rw-r--r-- | util/datamanager.lua | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua index 83f3dd13..dc98bd13 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -144,23 +144,26 @@ end local function atomic_store(filename, data) local scratch = filename.."~"; local f, ok, msg; - repeat - f, msg = io_open(scratch, "w"); - if not f then break end - ok, msg = f:write(data); - if not ok then break end + f, msg = io_open(scratch, "w"); + if not f then + return nil, msg; + end - ok, msg = f:close(); - if not ok then break end + ok, msg = f:write(data); + if not ok then + f:close(); + os_remove(scratch); + return nil, msg; + end - return os_rename(scratch, filename); - until false; + ok, msg = f:close(); + if not ok then + os_remove(scratch); + return nil, msg; + end - -- Cleanup - if f then f:close(); end - os_remove(scratch); - return nil, msg; + return os_rename(scratch, filename); end if prosody and prosody.platform ~= "posix" then |