We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dac2ea4 commit 8f67658Copy full SHA for 8f67658
1 file changed
skrub/datasets/_utils.py
@@ -274,7 +274,16 @@ def _extract_archive(dataset_dir, archive_path):
274
temp_dir = tempfile.mkdtemp(dir=dataset_dir)
275
shutil.unpack_archive(archive_path, temp_dir, format="zip")
276
path_source = Path(temp_dir) / dataset_name
277
- path_source.rename(dataset_dir / dataset_name)
+ path_target = dataset_dir / dataset_name
278
+ try:
279
+ path_source.rename(path_target)
280
+ except OSError: # pragma: nocover
281
+ if path_target.is_dir():
282
+ # another thread was fetching the dataset at the same time and
283
+ # beat us to it; no problem
284
+ return
285
+ else:
286
+ raise
287
except (Exception, KeyboardInterrupt):
288
try:
289
archive_path.unlink()
0 commit comments