@@ -509,6 +509,7 @@ function M.build(self, fast)
509
509
510
510
local dontWrite = self .dontWrite or r .dontWriteCache or cosmic :value (" LMOD_IGNORE_CACHE" )
511
511
local doneMsg
512
+ mrc = MRC :singleton ()
512
513
513
514
if (t2 - t1 < shortTime or dontWrite ) then
514
515
ancient = shortLifeCache
@@ -531,30 +532,26 @@ function M.build(self, fast)
531
532
dbg .print {" mt: " , tostring (mt ), " \n " , level = 2 }
532
533
doneMsg = " (not written to file) done"
533
534
else
534
- mrc = MRC :singleton ()
535
535
mkdir_recursive (self .usrCacheDir )
536
- local s0 = " -- Date: " .. os.date (" %c" ,os.time ()) .. " \n "
537
- local s1 = " ancient = " .. tostring (math.floor (ancient )) .. " \n "
538
- local s2 = mrc :export ()
539
- local s3 = serializeTbl {name = " spiderT" , value = userSpiderT , indent = true }
540
- local s4 = serializeTbl {name = " mpathMapT" , value = mpathMapT , indent = true }
541
- os.rename (userSpiderTFN , userSpiderTFN .. " ~" )
542
536
local userSpiderTFN_new = userSpiderTFN .. " _" .. uuid ()
543
- local f = io.open (userSpiderTFN_new ," w" )
537
+ local f = io.open (userSpiderTFN_new ," w" )
544
538
if (f ) then
539
+ os.rename (userSpiderTFN , userSpiderTFN .. " ~" )
540
+ local s0 = " -- Date: " .. os.date (" %c" ,os.time ()) .. " \n "
541
+ local s1 = " ancient = " .. tostring (math.floor (ancient )) .. " \n "
542
+ local s2 = mrc :export ()
543
+ local s3 = serializeTbl {name = " spiderT" , value = userSpiderT , indent = true }
544
+ local s4 = serializeTbl {name = " mpathMapT" , value = mpathMapT , indent = true }
545
545
f :write (s0 ,s1 ,s2 ,s3 ,s4 )
546
546
f :close ()
547
+ local ok , message = os.rename (userSpiderTFN_new , userSpiderTFN )
548
+ if (not ok ) then
549
+ LmodError {msg = " e_Unable_2_rename" ,from = userSpiderTFN_new ,to = userSpiderTFN , errMsg = message }
550
+ end
551
+ posix .unlink (userSpiderTFN .. " ~" )
552
+ dbg .print {" Wrote: " ,userSpiderTFN ," \n " }
547
553
end
548
554
549
- local ok , message = os.rename (userSpiderTFN_new , userSpiderTFN )
550
- if (not ok ) then
551
- LmodError {msg = " e_Unable_2_rename" ,from = userSpiderTFN_new ,to = userSpiderTFN , errMsg = message }
552
- end
553
-
554
-
555
- posix .unlink (userSpiderTFN .. " ~" )
556
- dbg .print {" Wrote: " ,userSpiderTFN ," \n " }
557
-
558
555
if (LUAC_PATH ~= " " ) then
559
556
if (LUAC_PATH :sub (1 ,1 ) == " @" ) then
560
557
LUAC_PATH = " luac"
0 commit comments