From 7238b370e4f2d25f496f30cc30b21c9f3c01b3b2 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 12 Mar 2019 00:03:34 -0400 Subject: [PATCH] builder.py: create temp log file in the same directory as the final one. We're going to rename() it from the temp name to the final name, which doesn't work across filesystems, so the safest option is to keep it in the same directory. Reported-by: spacefrogg@meterriblecrew.net --- redo/builder.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/redo/builder.py b/redo/builder.py index f983c67..01ada27 100644 --- a/redo/builder.py +++ b/redo/builder.py @@ -240,9 +240,15 @@ class _BuildJob(object): # reading a previous instance created during this session. It # should always see either the old or new instance. if env.v.LOG: - lfd, lfname = tempfile.mkstemp(prefix='redo.', suffix='.log.tmp') + lfend = state.logname(self.sf.id) + # Make sure the temp file is in the same directory as lfend, + # so we can be sure of our ability to rename it atomically later. + lfd, lfname = tempfile.mkstemp( + prefix='redo.', + suffix='.log.tmp', + dir=os.path.dirname(lfend)) os.fdopen(lfd, 'w') - os.rename(lfname, state.logname(self.sf.id)) + os.rename(lfname, lfend) dof = state.File(name=os.path.join(dodir, dofile)) dof.set_static() dof.save()