Skip to content

Commit e58b4c7

Browse files
committed
Temporarily unpacking a .b2z file defaults now to the same dir as the file
1 parent 034c0bf commit e58b4c7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/blosc2/dict_store.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class DictStore:
5858
and only when ``mode="r"``. Default is None.
5959
tmpdir : str or None, optional
6060
Temporary directory to use when working with ".b2z" files. If None,
61-
a system temporary directory will be managed. Default is None.
61+
a temporary directory is created in the same directory as the ".b2z"
62+
file, so that unpacked data stays on the same filesystem. Default is None.
6263
cparams : dict or None, optional
6364
Compression parameters for the internal embed store.
6465
If None, the default Blosc2 parameters are used.
@@ -165,7 +166,8 @@ def _setup_paths_and_dirs(self, tmpdir: str | None):
165166
self.is_zip_store = False
166167
if self.is_zip_store:
167168
if tmpdir is None:
168-
self._temp_dir_obj = tempfile.TemporaryDirectory()
169+
b2z_parent = os.path.dirname(os.path.abspath(self.localpath))
170+
self._temp_dir_obj = tempfile.TemporaryDirectory(dir=b2z_parent)
169171
self.working_dir = self._temp_dir_obj.name
170172
else:
171173
self.working_dir = tmpdir

src/blosc2/tree_store.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class TreeStore(DictStore):
105105
File mode ('r', 'w', 'a'). Default is 'a'.
106106
tmpdir : str or None, optional
107107
Temporary directory to use when working with `.b2z` files. If None,
108-
a system temporary directory will be managed. Default is None.
108+
a temporary directory is created in the same directory as the `.b2z`
109+
file, so that unpacked data stays on the same filesystem. Default is None.
109110
cparams : dict or None, optional
110111
Compression parameters for the internal embed store.
111112
If None, the default Blosc2 parameters are used.

0 commit comments

Comments
 (0)