Skip to content

Commit e975626

Browse files
committed
fix emptydirs
1 parent a984202 commit e975626

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

nipype/pipeline/engine/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def run(self, updatehash=False):
395395
self._interface.can_resume and op.isfile(hashfile_unfinished))
396396

397397
if rm_outdir:
398-
emptydirs(outdir)
398+
emptydirs(outdir, noexist_ok=True)
399399
else:
400400
logger.debug('[%sNode] Resume - hashfile=%s',
401401
'Map' * int(isinstance(self, MapNode)),

nipype/utils/filemanip.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,18 +699,22 @@ def makedirs(path, exist_ok=False):
699699
return path
700700

701701

702-
def emptydirs(path):
702+
def emptydirs(path, noexist_ok=False):
703703
"""
704-
Empty an existing directory, without deleting it
704+
Empty an existing directory, without deleting it. Do not
705+
raise error if the path does not exist and noexist_ok is True.
705706
706707
Parameters
707708
----------
708709
path : directory that should be empty
709710
710711
"""
711712
fmlogger.debug("Removing contents of %s", path)
712-
pathconts = os.listdir(path)
713713

714+
if noexist_ok and not os.path.exists(path):
715+
return True
716+
717+
pathconts = os.listdir(path)
714718
if not pathconts:
715719
return True
716720

0 commit comments

Comments
 (0)