]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
prefill: avoid rename syscall
authorPetr Špaček <petr.spacek@nic.cz>
Mon, 16 Apr 2018 11:59:56 +0000 (13:59 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 18 Apr 2018 15:08:28 +0000 (17:08 +0200)
An attempt to rename/move temporary file to its final destination will
fail if /tmp and working directory belong to different filesystems.

It seems that temporary file is not required so it easier to get rid of
it altogether.

modules/prefill/prefill.lua

index 19d89ecc558a0c6893e29109a0f43c53702fb46a..f74d711b0f492c2a6d2786855ba2f73f2786618b 100644 (file)
@@ -42,15 +42,12 @@ end
 
 -- Write root zone to a file.
 local function rzone_write(rzone)
-       local tmp_rz_fname = os.tmpname()
-       local file = assert(io.open(tmp_rz_fname, 'w'))
+       local file = assert(io.open(rz_local_fname, 'w'))
        for i = 1, #rzone do
                local rzone_chunk = rzone[i]
                file:write(rzone_chunk)
        end
        file:close()
-       os.rename(tmp_rz_fname, rz_local_fname)
-       -- TODO: IO error handling
 end
 
 local function display_delay(time)