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 <walters@verbum.org>
This commit is contained in:
Adrian Perez authored and Colin Walters committed 2012-05-04 16:16:16 -04:00
1 parent 717cec46c3
commit 0e266d3f92
1 file changed
+2 -1
+2 -1
View File
@@ -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)