Verified Commit 5b3d9810 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix temp file fixture re. owner changes

When temporary files were bind mounted into containers, then their
owner uid was changed, they could not be deleted during cleanup.
Solution is to put them in temporary directories and remove those.
parent 17ff4260
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ from base64 import b32encode as b32
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from tempfile import NamedTemporaryFile
from tempfile import TemporaryDirectory

from behave import fixture
@@ -89,10 +88,10 @@ def container_file(
			return

	# For unstarted containers, write to a temporary file and add it to the volumes mapping
	with NamedTemporaryFile("wb") as temp:
		temp.write(contents)
		temp.flush()
		container.volumes.append((Path(temp.name), path))
	with TemporaryDirectory() as tdir:
		temp = Path(tdir) / "temp.dat"
		temp.write_bytes(contents)
		container.volumes.append((temp, path))
		yield