Skip to content

Commit

Permalink
Use temporary folder in MDF4
Browse files Browse the repository at this point in the history
Use the temporary_folder value when copying the MDF4 file to a temporary location and use `gettempdir()` as fallback.
  • Loading branch information
alexander-ruehe committed Jun 10, 2024
1 parent c9d0e44 commit ba21f74
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/asammdf/blocks/mdf_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def __init__(

self._closed = False

self.temporary_folder = kwargs.get("temporary_folder", None)
self.temporary_folder = kwargs.get("temporary_folder", get_global_option("temporary_folder"))

if channels is None:
self.load_filter = set()
Expand Down Expand Up @@ -365,6 +365,8 @@ def __init__(

if version >= "4.10" and flags:
tmpdir = Path(gettempdir())
if self.temporary_folder:
tmpdir = Path(self.temporary_folder)
self.name = tmpdir / f"{os.urandom(6).hex()}_{Path(name).name}"
shutil.copy(name, self.name)
self._file = open(self.name, "rb+")
Expand Down

0 comments on commit ba21f74

Please sign in to comment.