From 0e266d3f9268bfaf260788902c611c5266106a9b Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Thu, 26 Apr 2012 18:21:27 +0300 Subject: [PATCH] ostbuild: Fix DB saving with /tmp and builddir in different volumes This fixes the case where /tmp resides in one volume, and the build directory in a different one: by storing the temporary file in the same directory as the target one, we avoid the case in which os.rename() would cross file system boundaries. Reviewed-by: Colin Walters --- src/ostbuild/pyostbuild/jsondb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ostbuild/pyostbuild/jsondb.py b/src/ostbuild/pyostbuild/jsondb.py index aecee359..6d7906e4 100644 --- a/src/ostbuild/pyostbuild/jsondb.py +++ b/src/ostbuild/pyostbuild/jsondb.py @@ -79,7 +79,8 @@ class JsonDB(object): current_time = time.gmtime() - (fd, tmppath) = tempfile.mkstemp(suffix='.tmp', prefix='tmp-jsondb-') + (fd, tmppath) = tempfile.mkstemp(suffix='.tmp', + prefix='tmp-jsondb-', dir=self._dirpath) os.close(fd) f = open(tmppath, 'w') json.dump(obj, f, indent=4, sort_keys=True)