Skip to content

Commit a151ca8

Browse files
committed
capture windows permission error (#3633)
Signed-off-by: Wenqi Li <[email protected]>
1 parent 5807f5d commit a151ca8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

monai/data/dataset.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ def _cachecheck(self, item_transformed):
335335
raise e
336336

337337
_item_transformed = self._pre_transform(deepcopy(item_transformed)) # keep the original hashed
338-
if hashfile is not None:
338+
if hashfile is None:
339+
return _item_transformed
340+
try:
339341
# NOTE: Writing to a temporary directory and then using a nearly atomic rename operation
340342
# to make the cache more robust to manual killing of parent process
341343
# which may leave partially written cache files in an incomplete state
@@ -354,6 +356,8 @@ def _cachecheck(self, item_transformed):
354356
shutil.move(temp_hash_file, hashfile)
355357
except FileExistsError:
356358
pass
359+
except PermissionError: # project-monai/monai issue #3613
360+
pass
357361
return _item_transformed
358362

359363
def _transform(self, index: int):

0 commit comments

Comments
 (0)