Software /
code /
prosody
Comparison
util/prosodyctl/cert.lua @ 13518:0ef9c26d9d96 0.12
util.prosodyctl.cert: Ensure old cert is moved out of the way
This should make it visible if the move fails
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 30 Aug 2024 17:41:40 +0200 |
parent | 12387:05c250fa335a |
child | 13520:662dfff658a0 |
comparison
equal
deleted
inserted
replaced
13513:2fb79fe54390 | 13518:0ef9c26d9d96 |
---|---|
161 local function copy(from, to, umask, owner, group) | 161 local function copy(from, to, umask, owner, group) |
162 local old_umask = umask and pposix.umask(umask); | 162 local old_umask = umask and pposix.umask(umask); |
163 local attrs = lfs.attributes(to); | 163 local attrs = lfs.attributes(to); |
164 if attrs then -- Move old file out of the way | 164 if attrs then -- Move old file out of the way |
165 local backup = to..".bkp~"..os.date("%FT%T", attrs.change); | 165 local backup = to..".bkp~"..os.date("%FT%T", attrs.change); |
166 os.rename(to, backup); | 166 assert(os.rename(to, backup)); |
167 end | 167 end |
168 -- FIXME friendlier error handling, maybe move above backup back? | 168 -- FIXME friendlier error handling, maybe move above backup back? |
169 local input = assert(io.open(from)); | 169 local input = assert(io.open(from)); |
170 local output = assert(io.open(to, "w")); | 170 local output = assert(io.open(to, "w")); |
171 local data = input:read(2^11); | 171 local data = input:read(2^11); |